0

This is a very strange scenario,

Suppose, I browse my site like "http://web.site.com" this way. my site display perfectly my Home page, on this page on the top, i am using one user control and this user control is displaying a logout Link button.

case 1: When i click this button in this scenario then its does not fired,

Case 2: But if i open my site like "http://web.site.com/default.aspx" then its work correctly and fired.

Can any one suggest me on this?

the below control is using in user control

<asp:linkbutton id="logoutLinkButton" runat="server" 
         onclick="logoutLinkButton_Click1">logout</asp:linkbutton>

and the Link button event code is

protected void logoutLinkButton_Click1(object sender, EventArgs e)
         {
             var url = this.Request.RawUrl;
             Authentication.Logout();
             Response.Redirect(url); 
         }
6
  • What is the code you have against that button ? Commented May 8, 2013 at 11:32
  • Check the logout link. I guess you are not using the login status control. Commented May 8, 2013 at 11:32
  • What url you have set to link? Commented May 8, 2013 at 11:33
  • Thanks to all i have edit my question and write the above code which i am executing Commented May 8, 2013 at 11:41
  • can you also give the html generated link tag on both scenario. Commented May 8, 2013 at 11:45

2 Answers 2

1

The problem is that you are using Request.RawUrl

The raw URL is defined as the part of the URL following the domain information. In the URL string http://www.contoso.com/articles/recent.aspx, the raw URL is /articles/recent.aspx. The raw URL includes the query string, if present.

so for your case "http://web.site.com" RawUrl would be empty, and thus not doing anything. Instead you can use Request.Url.GetLeftPart(UriPartial.Authority) like

protected void logoutLinkButton_Click1(object sender, EventArgs e)
{
   var url = this.Request.Url.GetLeftPart(UriPartial.Authority);
   Authentication.Logout();
   Response.Redirect(url); 
}
Sign up to request clarification or add additional context in comments.

6 Comments

Thanks, I have tried your code also but its not working, even i have not written a simple line like "Response.Write("Test"); " but it's also no fired in this simple case, but if i pass the default.aspx on the url then its write "Test" on the page.
@Priyank, that is strange, where did you put the Response.Write in your code. Make it first statement of the event
i have only written Response.Write Statement in my click event. and its does not write if i not browse my site with default.aspx
I just want to say, Link button click event not fired, if i not use default.aspx. i don't think this is related to link button code.
@Priyank, I am not sure why it is behaving like that, can you clean/rebuild the solution and try again ?
|
0

Try Request.URL' instead ofRequest.RawUrl`

1 Comment

no its still not working, even if i written only "Response.write("Test") instead of all code then is not write on the page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.