Redirect to asp.net login page

I have a site made in asp.net (vb.net as a backend). This site is localized http: // localhost / TEST . If I am in any aspx file, for example http: //localhost/TEST/about.aspx , I will be redirected to aspx login. Login.aspx is set as the start page in visual studio.

The problem is that if I am at http: // localhost / TEST , I get to a directory with a list of all aspx files.

How to redirect any user who visited http: // localhost / TEST to http: //localhost/TEST/login.aspx ??

+4
source share
3 answers

There are several mixed concepts in your post. Let's organize them.

Firstly, VS has a start page. This is the start page used when starting a website with or without a debugger. This only matters when starting the site from VS. After deployment to IIS, this no longer affects.

What you request is the default page that the user is redirected to if they do not explicitly point to the page. You can configure the default page in the web.config file as follows:

<system.webServer>
  <defaultDocument>
    <files>
      <clear />
      <add value="About.aspx" />
    </files>
  </defaultDocument>
</system.webServer>

You do not want to specify Login.aspx as the default page. Indicate the home page. If the user has already logged in, they should not automatically go to the login page, you want them to go to the home page.

, , , about.aspx, login.aspx. web.config. , .

<authentication mode="Forms">
     <forms name="asp.ASPXAUTH" loginUrl="login.aspx" protection="All" path="/"/>
</authentication>

, , , defaultDocument web.config.

+3

TEST - "default.aspx", , , .

+1

web.config .

<system.webServer>
  <directoryBrowse enabled="false" />
</system.webServer>
0

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


All Articles