I would like to do something like this:
if(Request == "mainPath")
{
//code here
}
So for example if the Request is coming from http://www.mydomain.com/tax/tax1 it would return true, but if Request is coming from http://www.mydomian.com/tax/tax1/image5.jpg or template.css it will not. What would be the best way to do it? I guess I could compare the url that's in the browser with the full path of the request but I am not sure if it's the best idea. Also, if it has any value to the question, the code exists in Application_BeginRequest() in Global.asax.cs - MVC3 project.
Thanks a lot!
It sounds like you're asking how to check the extension of the requested URL.
Check Path.GetExtension(Request.Url.LocalPath)
.
You might also want to check File.Exists(Server.MapPath(Request.AppRelativeCurrentExecutionFilePath))
.