views:

877

answers:

9

Hi

Thanks for going to answer my question. I have the folowing pages.

  • login.aspx
  • default.aspx
  • xxx.aspx

After logging into application default.aspx will be displayed. Now if the user is trying to open http://server/xxx.aspx?Id=1234 by specifying its URL directly in a browser, the login screen is displayed and after successfull login, system redirects to "default.aspx" and not to "http://server/xxx.aspx?Id=1234". Actually there is an external application that would call my system like that. So Please let me know why is this happening. The .Net login control is used to login into the application. Kindly help me to solve this issue.

Thanks,
Ang Vin

A: 

Response.Redirect(Request.UrlReferrer.ToString());

Markus Nigbur
A: 

No I dont know how login.aspx calls default.aspx. I am not sure if thats the default behaviour of login control. If login.aspx calls default.aspx thru some c# code then I can use Response.redirect. But the problem is I don know how it is getting called. So what is the solution?

AngVin
+2  A: 

Are you using Forms Authentication or doing this directly in the application? If you do something like this in your web.config it will handle all the redirecting for you.

<authentication mode="Forms">
      <forms name="FwLoginCookie" loginUrl="Login.aspx"
        protection="All" 
        path="/" >
      </forms>
     </authentication>
     <authorization>
      <deny users="?"/>
     </authorization>

Is there anything in the URL stating the ReturnURL? With the above setting if the user tries to go to xxx.aspx I would expect the URL of the login dialog to look like "Login.aspx?ReturnUrl=xxx.aspx"

wonderchook
A: 

Thanks for the response once again. Yes system uses Forms Authentication like the one that u have specified. But how can I avoid redirecting to default.aspx when the user wishes to open xxx.aspx by directly specifying the address in the URL.

AngVin
A: 

I have the following in my web.config file

<authentication mode="Forms" >
  <forms name="Auth" loginUrl="~/Login.aspx" protection="All" timeout="1440" path="/" />
</authentication>
<identity impersonate="true" />
AngVin
A: 

When you go to xxx.aspx and it redirects you to login.aspx, what is the full url being shown for the login page? It should look something like "http://server/login.aspx?ReturnUrl=xxx.aspx".

Greg
A: 

Check that you are NOT setting the DestinationPageUrl property in the login control:

<asp:Login 
  ID="Login1" 
  runat="server" 
  DestinationPageUrl="~/Default.aspx">
</asp:Login>

I assume you have as this property overrides the default behaviour you are actually looking for.

HectorMac
A: 

I have checked and it looks like 'DestinationPageUrl" is not set anywhere

AngVin
A: 

Greg, The full URL is lke the one below
http://server/xxx.aspx

Actually my system will be used by external application as well. So when external application calls my system using the URL - "http://server/xxx.aspx?Id=1234" they ll be redirected to "login.aspx" and then it should go to "http://server/xxx.aspx?Id=1234", instead its going to default.aspx which is not the expected behaviour.

AngVin