Reputation: 1
In ASP.Net 4, I could use Razor views as pure CSHTML without tying them to any MVC controller, basically I just wanted the lightweight layout and ability to call server side code when needed.
How do I do that in ASP.Net core? I've placed a CSHTML in wwwroot but the server won't serve it. Is there any particular service or provider I need to add into the startup class?
Thanks!
Upvotes: 0
Views: 1496
Reputation: 3429
There is no default controller. not in ASP.NET MVC 4 or Core. But what you can do is to create one. Simple ASP.NET MVC views without writing a controller
But what I'm actually assuming you're asking for is a .cshtml
page that performs nothing, only HTML and Javascript (and with that make calls to partials, then again you need controllers). If that is what youre after then make a .html
page in /wwwroot
and not a .cshtml
and enable static files in Startup.cs
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
app.UseStaticFiles();
and lastly, another thought, I think that you are not after MVC at all but rather ASP.NET Web Pages. By the looks of it the "asp.Net Web Pages" a.k.a loose cshtml looks to be dead in core, but a solution whould be a default controller on it.
Upvotes: 1