How to force default.aspx instead of www.domain.com

OK I have a funny problem. I am trying to use URL rewriting to redirect from www.domain.com to www.domain.com/default.aspx.

I thought setting default.aspx as the default document that will automatically delete the user. But for some reason, he still appears on www.domain.com.

The reason I want to go to www.domain.com/default.aspx is because the entry control on the page does not seem to want to work when it is just a www.domain.com site. But, of course, if I type on www.domain.com/default.aspx, then the login works fine. The entry control does not seem to be published at all if it is www.domain.com. Anyway, I try to avoid troubleshooting why login control does not start and just force it to land on default.aspx anytime when someone tries to go to www.domain.com. I am using IIS7. Any ideas here?

+4
source share
2 answers

Anwer is concerned with breaking changes in ASP.NET 4. The answer was that the form action was empty action="" when on the root url without extension. but if on the same page but has the page name in url (blahblah.com/default.aspx), the action is populated. An easy solution for me was to put Me.Form.Action = "Default.aspx" on the page load at home page. The problem was fixed.

+5
source

You can add something like this to your Default.aspx standard (in your Page_Load method):

 if (Request.Url.LocalPath == "/") { Response.Redirect("~/Default.aspx"); } 

Note that the default document setting usually allows you to display this page in the www.domain.com/ section and www.domain.com/default.aspx (it does not redirect you).

+5
source

Source: https://habr.com/ru/post/1341557/


All Articles