开发者

Asp.Net page reload problem after login

I am devolping a web application.the problem is that i am using a login control (not a .NET control) which is a part of master page and is acessible开发者_开发问答 from all pages. if user log In from a page the login control updates itself and displlay some statistics of logged In user but the specific page does not reload. (some options on page are visible only to authenticated users, so that after login, page should be reloaded to display such options)

after logIn methoed I wrote

Reponse.Redirect(Request.Url.AbsoluteUri)

after this the browser response the "Page cannot be displayed"

It would be of great help to me.

Many Thanks, Regards. AZHAR


From you description it is not clear what happens, but with high possibility you get infinite loop, when page is redirected to itself again and again.

Most obvious problem that you place redirect code in Page_Load,

as possible resolution:

  1. Place Reponse.Redirect(Request.Url.AbsoluteUri) to OnLogin event of your login control
  2. if you anyway want use Page_Load, at least add following check:

    if(IsPostBack) Reponse.Redirect(Request.Url.AbsoluteUri)

But last case is very bad style because may have lot of side effects.


  1. Make sure your redirect is not causing a loop. Check Page.IsPostBack

  2. Be aware that POST variables are lost during this operation.


Another thing that you should look at is the roles that you allow in the folder (in the web.config file in the folder).

I accidentally misspelt a role name and it kept redirecting my users to the login page.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜