1

I have several sections

<location path="Page1.aspx">
    <system.web>
      <authorization>
        <allow roles="superadmin"/>
        <deny users="*" />        
      </authorization>
    </system.web>    
</location>

<location path="Page2.aspx">
    <system.web>
      <authorization>
        <allow roles="admin"/>
        <allow roles="superadmin"/>
        <deny users="*" />
      </authorization>
    </system.web>
</location>

I want to make a redirect to the specified page if authorization failed. And this is not general page. I want to make a specific redirect based the page user wants to open. How it can be done?

Thanks in advance.

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Alexander
  • 11
  • 2
  • Once you put authorization for a particular page, the login page shall redirect you to the same Url{return url} that you requested, so what do u mean by specific redirect?? – Furqan Hameedi Mar 06 '11 at 12:00
  • We could deduce, but it would help if you told us the problems you ran into on trying. The idea you have seems correct, though I'm not sure .NET would complain about the `location path` being a file name as opposed to a folder path. Ultimately, if you get no complaints, then can't you add a `location` section per page requiring specific redirects? – Grant Thomas Mar 06 '11 at 12:05

3 Answers3

0

The error/login page receives the original page as a parameter that is passed to it. You could add code to the error/login page that would redirect based on that parameter. Each page would need to be specified in the web.config to allow all users access to it since the user isn't logged in of course.

Thyamine
  • 1,228
  • 7
  • 10
0

I think you are going to have to use your own custom authentication scheme. AFAIK, Forms authentication uses the same login page for the entire web application.

Tundey
  • 2,926
  • 1
  • 23
  • 27
0

Forms Auth? Use asp:Login control and LoginError event

or

Specify the loginUrl

<system.web>
    <authentication mode="Forms">
        <forms name=".ASPXFORMSAUTH" loginUrl="Login.aspx" ... />
    </authentication>
</system.web>

where user will be redirected in case of auth failure with redirectUrl in query.

abatishchev
  • 98,240
  • 88
  • 296
  • 433