-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Razor Class Library - Static File Path #14562
Comments
Usually that happens when you're missing a call to I'm not sure that's you're problem though since you're using |
Is UseApplication defined in a different assembly?
|
I've attached a simple sample application which shows the problem. |
This seems like an issue in @javiercn 's static file manifest stuff. |
Bouncing over to MVC because it seems to be an issue in the static files support in Razor Class Libraries and I don't have a ton of context there. |
With current sample WebApplication1.zip, without any modification. The static file 404 only happen when we running on IISExpress. |
@nfplee Seems you are not using generic host. There might be an issue lurking with the old hosting mode. I'd recommend you move to use generic web host and that should fix it, if not, alterntively try calling UseStaticWebAssets on your IWebHostBuilder and that should also fix it. |
@javiercn I am using the generic host. See my original post and my sample. I've also tried calling UseStaticWebAssets but it did not make a difference. |
@nfplee I downloaded your app and it doesn't seem to be using generic host. In any case, I switched it to use generic host and found that the issue is that you are passing in the full name (which contains version, etc) and that causes issues when static web assets tries to find the manifest file. If you switch it to use the assembly simple name, everything works:
Alternatively, you can pass in the path to the static web assets manifest by providing the path in the setting So to summarize it:
|
Closing this issue as there's no more action for us to take here. |
@javiercn - Thanks, it looks like I over simplified the example as I thought I was using the generic web host. I used the generic web host in the original question. Your fix also seems to have done the trick. |
I'm trying to remove the Startup class in my application. Therefore I have the changed the CreateHostBuilder method in my Program class to the following:
Where UseApplication looks like:
Note: Without the UseSetting(WebHostDefaults.ApplicationKey, entryAssemblyName) line the application doesn't run at all.
However I am having issues where the path to my static files in my razor class libraries (e.g. "~/_content/MyLibrary/js/app.js") now returns a 404.
I found that if I call the Configure extension method in my Program.cs file instead of the UseApplication extension method then it works fine so I tried looking into the source to see if I can fix it but so far everything I have tried has not worked.
I'm not sure if this is a bug or if there is some way to configure it that I have not found. I'd really appreciate the help.
Thanks
The text was updated successfully, but these errors were encountered: