Question

enter image description here

This is my solution structure.
When users hit in this http://localhost/RouteUrl/ URL I want to redirect them to http://localhost/RouteUrl/UI/MainForm.aspx.

In web.config file within system.web section I've written:

<urlMappings enabled="true">
  <add url="~/RouteUrl" mappedUrl="~/UI/MainForm.aspx" />
</urlMappings>

And when I browse http://localhost/RouteUrl/ it shows HTTP Error 403.14 - Forbidden. The Web server is configured to not list the contents of this directory When I directly browse http://localhost/RouteUrl/UI/MainForm.aspx it simply shows the page, doesn't show any error.

I don't want to enable directory browsing. What I'm missing? How I should properly redirect the URL?

Was it helpful?

Solution

Finally I find out the problem. The ~ itself points to the root directory and in <add /> tag I've written url="~/RouteUrl".

So the corrected <add /> tag will be:
<add url="~/" mappedUrl="~/UI/MainForm.aspx" />

OTHER TIPS

I believe your issue is with the trailing /. Your route is to ~/RouteUrl and you are entering ~/RouteUrl/, which would act as the root of a directory and with directory browsing is turned off, you receive a 403 error.

Adding <modules runAllManagedModulesForAllRequests="true" /> to the <system.webServer> section in the web.config works for me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top