Authentication and return url
After login my page i opened different links my page the link passed with query string
ex: http://localhost/document/doc.aspx?aaa=ddd
when i remove query string in url and copy the url and open new browser and paste the url when i 开发者_开发知识库press the enter doc.aspx page is opening I want Redirect the login page this time. I have number pages in my application how can i do this. We are using forms authentication
This is in-built behaviour with the ASP.Net Membership Provider - it'll check authentication before accessing any protected URL.
When you talk about "opening a different browser", do you mean a new instance of the same browser, i.e. 2 windows of Internet Explorer, or an instance of a different browser, i.e. 1 window of Firefox, 1 window of Chrome? If you are using the same browser, it will still have the authentication cookie, and still be authenticated, but if you open a different browser (that doesn't share cookies with the other one), then you'll get your redirect behaviour. If you were to copy/paste your link to someone else, they would of course be redirected because they don't have an authentication cookie except when they are currently logged in as themselves.
You need to ensure that your page / folder is locked down in web.config.
The element lets you specify a path to a file (/document/doc.aspx) or an entire folder (/document/). You can then lock this down by various criteria, such as any authenticated user, specific role(s), specific user(s).
Look in your web.config and make sure the down at the bottom there is the following (put it between </runtime>
and </configuration>
:
</runtime>
<!-- access permissions -->
<location path="/document/">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
</configuration>
As you can see from this example I have locked down the entire folder (path="/document/"
) from any unauthenticated users (<deny users="?"/>
).
精彩评论