views:

115

answers:

3

I'm using the UrlRewriting module on my site and I can't seem to get HttpContext.Current.Request.IsAuthenticated to return "true" on any rewritten pages.

If I go to my home page (http://localhost/default.aspx) I get "true", but if I go to something like (http://localhost/contactus) I am always getting "false".

why would this be?

also, for a direct example, I have an edit bar that is supposed to appear to anyone who is authenticated. The if statement fires in the Page_Load method

If HttpContext.Current.Request.IsAuthenticated Then _ 
Me.FindControl("EditBar").Visible = True

I have also tried putting this in the page load event

Response.Write(HttpContext.Current.Request.IsAuthenticated.ToString)

Every page that is rewritten says "False" where pages that are not rewritten say "True".

A: 

I had a similar issue. Does adding the following to your web.config fix your problem?

<modules runAllManagedModulesForAllRequests="true">
Sam
unfortunately no, I've been running with that since the beginning.
rockinthesixstring
A: 

Hmm, wherever the code in my question DIDN'T work, then this code did.

User.Identity.IsAuthenticated
rockinthesixstring
A: 

Where did you put User.Identity.IsAuthenticated?

Curt McClements
Since SO isn't a forum, you should not "answer" a question, but rather use a comment. I used it like this. `If User.Identity.IsAuthenticated Then 'dosomething`
rockinthesixstring
Thanks, rockinthesixstring! My problem is that on pages with rewritten urls (which consequently don't require authentication on my website), even if the user has logged on, the User.Identity.IsAuthenticated returns "false". This would be no big deal except I need the page to display the correct loginstatus in the login control for users that have already logged in . i.e., "Welcome, John my account | log out"
Curt McClements