I have an ASP.NET vNext project with the web start template. I've added a new html file and I wish to run it. However when I go to localhost:1111/index.html I get 404 error. Is there a special configuration in the grunt file?
Type start followed by the HTML file name and press ↵ Enter . For example, if you wanted to run your index HTML file, you would type start index. html and press Enter. This launches the HTML file in a separate window allowing you to preview your HTML file.
Visual Studio offers powerful HTML, CSS, JavaScript, and JSON editors. Tap into the power of LESS, and Sass, use PHP, Python, or C# with ASP.NET. All the popular languages are supported and you can move between languages and project types with ease.
The HTML file needs to be inside the root of wwwroot folder. You can move the file manually inside the folder and then edit it from inside wwwroot folder. Alternatively set up a Grunt task to copy it to the wwwroot folder using grunt-contrib-copy.
Depending on how you are hosting the project you will then have to enable static files. One way is to use the AspNet Static Files package.
In the project.json add with the beta version you are using (it is there by default in some project templates)
"Microsoft.AspNet.StaticFiles": "1.0.0-beta3",
In the Startup.cs tell the app to use static files (this is also added by default in some templates)
app.UseStaticFiles();
Then this should work...
Also the wwwroot folder is just the default in the starter template, you can change this by looking in the project.json file and changing the webroot property
"webroot": "wwwroot",
In your case you could change it to "." which would set the webroot to be the project folder but I think it is much better to have the "wwwroot" folder which makes it easier to control what can be accessed statically. If you use any languages which needs to be processed into static files, for example SASS and TypeScript, then it is a nice workflow to have the source files outside the webroot and then process them and set the destination to the webroot.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With