Reputation: 18825
I have a directory in my project that I want all calls to web pages within it and any sub directories to be diverted to another web site.
Eg.
If the directory is http://localhost/MyProject/MyDirectory, I want all URLs such as http://localhost/MyProject/MyDirectory/MyFile.aspx to be diverted to another web site.
I do not want to use IIS for this as there are some additional business rules relating to dates and stuff. There I was thinking of doing it in either my master page or in my global.cs file.
How though do I know whether the request is actually in the directory.
I was going to just go
if(Request.Url.AbsoluteUri.contains("http://localhost/MyProject/MyDirectory) { Response.Redirect("...") }
But I feel that's not that good of a solution since may be in different domain names etc.
Upvotes: 2
Views: 46
Reputation: 99957
You could use Request.Url.AbsolutePath
to get the path after the domain name.
Upvotes: 1