2
votes

I'm using form authentication in my asp.net website. Currently I have my authentication setting in web.config as below.

<authentication mode="Forms">
      <forms loginUrl="~/Account/Login.aspx" timeout="60" cookieless="UseCookies" defaultUrl="~/landing.aspx" protection="All" slidingExpiration="true" />
    </authentication>

I want to navigate to landing.aspx page before login.aspx page then on a button click on the landing page go to login.aspx page.

2

2 Answers

4
votes

I'm assumimg you are using web forms (versus MVC).

The first step is to create a landing page in your project. Probably you will want it in the root of the site. Let's assume it is called LandingPage.aspx.

Add the following inside the <configuration> tag of your web.config. This will allow people to access the landing page without having to log in first.

<location path="LandingPage.aspx">
    <system.web>
        <authorization>
            <allow users="?"/>
        </authorization>
    </system.web>
</location>

Next, in IIS Manager, configure a default document for the web site that points to LandingPage.aspx. This will ensure that new visitors are directed to the landing page when they navigate to your web site.

Lastly, you just need to fill out the content of the landing page, and make a "Sign in" button somewhere that will take users to the Login page when they want to log in. I leave that to you.

0
votes

We can also configure default page from web config file with below tags

<system.webServer>
    <defaultDocument>
        <files>
            <add value="default.aspx" />
            <add value="Default.htm" />
            <add value="Default.asp" />
            <add value="index.html" />
            <add value="index.htm" />
            <add value="iisstart.htm" />
        </files>
    </defaultDocument>
</system.webServer>