I know this is a very odd request but to cut a long story short a developer have the wrong URL that has now been printed on material. The url was a .cshtml file which obviously is not allowed to be hit through IIS.
I need to allow this particular cshtml or all of them to be rendered as plain html in the browser.
Help will be appreciated.
You could use the Application_BeginRequest event to check the extension of the file and apply some logic then redirect them.
In Global.asax.cs file:
You can use the IIS mod_rewrite extension with a regex for all cshtml files, or just this particular one.
http://www.iis.net/downloads/microsoft/url-rewrite
OR, in the IIS manager use the MIME Types configuration and add .cshtml as type text/html
This might not NOT the best solution, but it is the one I know of the top of my head.
Go to your Global.asax file. From there go inside of or create the Application_AcquireRequestState function as so:
void Application_AcquireRequestState(object sender, EventArgs e) { }
Inside the above function check to see if the path matches your .cshtml file. If so, do
Server.Transfer
to a regular aspx page.You might also have to go into IIS settings and enable cshtml to be served.