2 Replies - 2005 Views - Last Post: 15 October 2009 - 06:14 AM

#1 arthurakay   User is offline

  • D.I.C Head

Reputation: 22
  • View blog
  • Posts: 226
  • Joined: 17-February 09

WebForms Authentication - Logging out

Posted 12 October 2009 - 09:38 AM

I've got a problem understanding how to create a logout button for my application. I've built the login page successfully using WebForms Authentication.

The main page (/Default.aspx) uses server-side includes to build my application. At the top of my page, I include a file from another directory (/Page/North.aspx) which has my logout button:
<form runat="server" id="form1">
	<div id="region-north">
		<div id="region-north-logo"></div>
		
		<div id="region-north-username">
			<p align="right">
				<asp:Button id="logoutButton" 
							runat="server" 
							Text="Logout" 
							onclick="Logout_onclick" /><br />
				<%= System.Web.HttpContext.Current.User.Identity.Name %>
			</p>
		</div>
	</div>
</form>



And the code-behind file (North.aspx.cs):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

public partial class Page_North : System.Web.UI.Page
{
	protected void Page_Load(object sender, EventArgs e)
	{

	}
	
	public void Logout_onclick(object sender, EventArgs args) 
	{
		FormsAuthentication.SignOut();
		Session.Abandon();
		Response.Redirect("/");
	}
}



The page renders fine, but the logout button doesn't work correctly. Clicking the button, I get a page displaying this error:

The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /North.aspx

So I understand that the error is saying it can't find the file "/North.aspx", but I'm confused why I'm seeing the error in the first place. "North.aspx" resides in the "/Page/" folder... why isn't it looking for it there?

I'm guessing it has something to do with my use of SSIs, but I'm hoping someone can help clarify the issue.

Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: WebForms Authentication - Logging out

#2 ramesh866   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 91
  • Joined: 03-October 09

Re: WebForms Authentication - Logging out

Posted 14 October 2009 - 11:55 PM

in the response.redirect url, why you have included '/' ? just try response.redirect("North.aspx");
Was This Post Helpful? 0
  • +
  • -

#3 arthurakay   User is offline

  • D.I.C Head

Reputation: 22
  • View blog
  • Posts: 226
  • Joined: 17-February 09

Re: WebForms Authentication - Logging out

Posted 15 October 2009 - 06:14 AM

View Postramesh866, on 14 Oct, 2009 - 11:55 PM, said:

in the response.redirect url, why you have included '/' ? just try response.redirect("North.aspx");


After clicking on the button, the idea is that the user gets redirected to my domain root - hence the "/". Regardless, this line of code is never executed because .NET can't find the code-behind file... and I think it's because I'm including "/Pages/North.aspx" via SSI inside "/Default.aspx".
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1