goldfinger
goldfinger

Reputation: 1115

.NET MVC - accessing .xhtml file

I have created an Area for XForms and when I try to return view("index.xhtml") the framework resolves the view as index.xhtml.aspx or index.xhtml.cshtml.

I tried routes.IgnoreRoute("{resource}.*xhtml/{*pathinfo}"); in global.asax.

Either I am not sure what URL to use (am I still hitting the controller or going straight at the .xhtml file in the views folder?) OR I made a mistake in my ignoreroute.

Any help appreciated.

Upvotes: 1

Views: 169

Answers (1)

moribvndvs
moribvndvs

Reputation: 42497

If you are trying to have the action just write the content of index.xhtml, you'll need to do return File("index.html", "application/xhtml+xml"). View/PartialView assume you want the specified view file parsed and executed using the currently configured view engine.

You can't/shouldn't put static files you want remote users to be able to hit directly in your ~/Views folder. MVC places a web.config file in this folder that prevents files in this location from being served.

So, either have your controller action return the file as I mentioned above, or move the xhtml files into some other folder in your application that is not restricted. Then your route should work and your files should be served statically.

Upvotes: 1

Related Questions