IsAuthenticated Not Recognized On Rewritten Pages?

Jan 2, 2010

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".

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".

View 3 Replies


Similar Messages:

Web Forms :: How To Get Rewritten URL After URL Rewriting

Oct 5, 2013

I have a page default.aspx inside display folder : 

i use url-rewriting given below :

<rewrite url="~/comment/(.+)" to="~/files/default.aspx?section=$1" />

 In my code behind i want to get re-writting path but when i m using 

path = Request.Url.ToString();

It is fetching original path  like abc.com/files/default.aspx?section='asr'
 
I want to get : abc.com/comment/asr

View 1 Replies

Url Rewriting - How To Read Rewritten Url From Web Page

Jan 15, 2010

Most of the resources on the Internet seems to discuss how to do url rewriting in asp.net. None of them seem to discuss about how to read the rewritten url.For example, I have rewritten:

http://www.test.com/users.aspx?id=12&name=sangam

to
http://www.test.com/profile/12/sangam.aspx

Now in the same page, at some point, I want to get this rewrittern url for the purpose of pointing return url in login link. Now a login link should be:

http://www.test.com/login.aspx?ReturnUrl=/profile/12/sangam.aspx

View 1 Replies

Web Forms :: Refresh Page Which Has Rewritten Url?

Apr 8, 2010

I'm trying to refresh my page when a user clicks a button; my problem is that my site uses URL rewrites.

In the past I've used Response.Redirect(Request.Url.ToString()); to achieve this, but my problem is that when I do this it does not display the rewritten URL but the URL which has my parameters specified.

For example my page is www.mydomain.com/products/cars but when i do the Response.Redirect(Request.Url.ToString()); on this I get this www.mydomain.com/products/default.aspx?type=cars My client has demanded URL rewrites throughout the site.

View 3 Replies

Reference Rewritten Address With Request.Url?

Feb 25, 2011

I am using a custom asp.net rewriting module for some time now, and I would like to know how to reference/get a rewritten address (the url that shows in address bar) of an original url using Request.Url?

When I reference url with Request.Url.AbsoluteUri I always get the original address and not the rewritten one. One solution is to encode the original url once again, but I was looking for a different solution where I could actually reference this new url.

View 1 Replies

Configuration :: Rewritten Url Gets Changed After Page Postback

Aug 5, 2010

I have done outbound rule for anchor(A) tag. after clicking an anchor tag the page gets redirected to the specified page with rewritten url. but when i change value from dropdown list or click on any button on that page, the page url gets changed to old url(the original url for which we did new url.) so i dont want that url to be changed. how can i do that.

View 1 Replies

State Management :: Accessing Session With Rewritten URL

May 21, 2010

I've searched these forums, found some pretty similar problems, but haven't found solution to the following:

I'm using simple engine (IHttpModule hooks to BeginRequest) to rewrite some URL on the site and everything works perfectly as long as original URL ends with .aspx, example:

http://site/articles/Article-name.aspx rewrites to real location
http://site/DisplayArticle.aspx?name=Article%20name

Tries to use any other URL which DOES NOT end with .aspx results in that Page.Session throws an exception and Page.User is always null (Forms Authentication) Integrated Visual Studio development server works fine in any way, this is only happens when I'm trying local IIS or hoster machine.

View 3 Replies

VS 2010 / Page Rewritten Before Button Event?

Jun 14, 2012

I have a textbox and a button on a page. When the user clicks the button, it calls a function in the codebehind that inputs the text from the textbox into a sql table. Or at least it should. I can't get it to work properly.

Here's what I have.

ascx file:

Code:
<asp:Label ID="lblTicketComments" runat="server" Visible="false"></asp:Label>
<asp:TextBox ID="txtNewCommentText" runat="server" CssClass="NewCommentText" TextMode="MultiLine"></asp:TextBox>
<asp:Button id="btnNewCommentSubmit" Text="Add Comment" runat="server" OnClick="NewCommentSubmit_Click" />
ascx.cs file:

Code:
protected void Page_Load(object sender, System.EventArgs e)
{
btnNewCommentSubmit.Click += new EventHandler(this.NewCommentSubmit_Click);
if (UserCanSeeThisTicket())
{
PrintTicketComments(); //outputs the comments to lblTicketComments
PrintlblNewTicketStuff();

[code]....

It seems the page is being reloaded before PostComment(); is ever executed, because no matter what I type in the text box, it always posts to SQL as "Write Comment Text Here..." However, if I remove the button click even and just put PostComment() in Page_Load under if(this.IsPostBack), it works fine. (but this is not ideal because I will need other buttons later which will cause a postback) So what am I doing wrong?

View 4 Replies

Button Event OnClick Not Raised After Redirecting To Rewritten URL?

May 7, 2010

This is driving me nuts, I cant figure out why the event OnClick doesn't fires when using a rewritten url (using URLRewritngNet).

Buttons lies everywhere on several pages and at the master page too.

View 3 Replies

Security :: Request.IsAuthenticated Between Websites

Feb 10, 2010

i have 2 websites, website1 has window.open link to the website2, authentication is forms (and windows but in web.config is set to forms) for both websites, when i click on the link and debug Request.IsAuthenticated should be true or false? both applications are running on the same machine

View 2 Replies

C# - Request.IsAuthenticated Problem With Cache In Asp?

Mar 26, 2010

When I want to cache I View or an Action like this :

<%@ Page title="" language="C#" masterpagefile="~/Views/Shared/MemberHome.Master" inherits="System.Web.Mvc.ViewPage<IndexViewData>" %>
<%@ OutputCache duration="400" varybyparam="divId;regionId;page" %>

I know that it cache all data in my page ... But in my page I have a condition like this :

<% if(Request.IsAuthenticated) { %>
<a href="/fr/Advertiser/Search"><img src="/content/images/v_2/bot.jpg" alt="Entreprises liées à vos passions" title="Entreprises liées à vos passions" /></a>
<% } else { %>
<a href="/fr/Advertiser/OpenSearch"><img src="/content/images/v_2/bot.jpg" alt="Entreprises liées à vos passions" title="Entreprises liées à vos passions" /></a>
<% } %>

I dont want to cache this variable : Request.IsAuthenticated ... because some result depend of this condition ... I try the donut caching by scottgu's but it return (I think) just some text not a bool ...
http://weblogs.asp.net/scottgu/archive/2006/11/28/tip-trick-implement-donut-caching-with-the-asp-net-2-0-output-cache-substitution-feature.aspx

Now I'm tired to try anything that come to my mind .

View 2 Replies

C# - Request.IsAuthenticated Is Failed On Server?

Feb 21, 2011

Request.IsAuthenticated condition failed on server after I deploy the code. It is working for me when I ran from local server.

FormsAuthentication.RedirectFromLoginPage("user", True)
Session("user") = mUser
Response.Redirect("~Clients.aspx")

I am checking

Request.IsAuthenticated

in Clients.aspx page load. There it is failing.

How can I work it on server also ?.

View 1 Replies

Context.User.Identity.IsAuthenticated Always Authenticated?

Mar 3, 2011

I am trying to create a httphandler which will intercept a sample pdf file which we have in our website. The httphandler works fine from within my development machine and even my locally published website that if I just try to connect to the test url: [URL] I will get sent to the invalid access page. So pushing it to our IIS6 machine when I try to go to the URL it serves up the PDF document. context.User.Identity.IsAuthenticated is always showing as true. I'm using forms authentication. below is the code I am using as the handler.

public void ProcessRequest(HttpContext context)
{
if (context.User.Identity.IsAuthenticated)
{
string SampleURL = context.Request.AppRelativeCurrentExecutionFilePath;
context.Response.Buffer = true;
context.Response.Clear();
using (FileStream fs = new FileStream(HttpContext.Current.Server.MapPath(SampleURL),FileMode.Open))
{
int length = (int)fs.Length;
byte[] buffer;
using (BinaryReader br = new BinaryReader(fs))
{
buffer = br.ReadBytes(length);
}
context.Response.Clear();
context.Response.Buffer = true;
context.Response.ContentType = "application/pdf";
context.Response.BinaryWrite(buffer);
context.Response.End();
}
}
else
{
context.Response.Redirect(
"~/Error/invalid_access.aspx");
}}

in web.config I have the following for form authentication:

<authentication mode="Forms">
<forms name="Sample.Web" loginUrl="~/Security/" defaultUrl="~/default.aspx" protection="All" timeout="60" path="/" requireSSL="false" slidingExpiration="true" enableCrossAppRedirects="false" cookieless="UseDeviceProfile" domain="">
</forms>
</authentication>
<authorization>
<deny users="?"/>
</authorization>

View 3 Replies

.net - How To Set Request.IsAuthenticated To True When Not Using FormsAuthentication.Redirect

Jan 20, 2010

I am using Form Authentication and sending an Aajx request to the server for authentication. Based on the json result, the client decides where to go and what to do. That is the reason I am not using FormsAuthentication.RedirectFromLoginPage to not interfere the ajax/json response.In this case Request.IsAuthenticated returns false, even after validating the user with Membership.ValidateUser. Then I set the cookie using FormsAuthentication.SetAuthCookie(username, false)

View 2 Replies

Windows Authentication Succeeds But IsAuthenticated == False?

Jun 29, 2010

Environment is IIS 7 integrated pipeline, ASP.NET 4.0. I have a .aspx page configured without anonymous authentication and with windows authentication:

<location path="auth/windows">
<system.webServer>
<security>

[code]...

When I request the page, a normal Windows auth (NTLM/Negotiate) challenge response happens, and ultimately the page is returned.I have an HttpModule in which I handle the PostAuthorize event. As expected, this event is only raised once the challenge-response authentication has succeeded and access to the page has been authorized.However, the Request.IsAuthenticated property is false; and HttpContext.Current.User.Identity reflects an unauthenticated user (.Name returns the empty string). Interestingly, Request.ServerVariables["LOGON_USER"] does return the value of the authenticated Windows user.I'd have thought that once the user was authenticated (and authorized, for that matter), the request would reflect being authenticated; and the User / Identity for the request would have been properly set.

View 1 Replies

MVC :: Forms Authentication User.Identity.IsAuthenticated And Cookie?

Feb 9, 2010

I am using forms authentication and have an issue with a particular browser using the remember me feature. For various reasons I want to support the opera browser that works with the nintendo dsi. I can use forms authentication with that browser just fine but when I use the remember me (cookie) feature I can get through the login but then calls to User.Identity.IsAuthenticated return false. If I do not check remember me it works fine. Initially I thought the browser didn't support cookies but it does. At least I can go to m.gmail.com and check their version of remember me and it works. I can exit the browser and come back in and m.gmail.com remembers me. Also I don't have problems with remember me on any other browser I have tried.

Is anyone aware of some specific browser issue that doesn't work with asp.net forms authentication? I am using asp.net mvc but I doubt that matters.

View 3 Replies

Security :: How To Set Request.IsAuthenticated To True When Not Using FormsAuthentication.RedirectFromLoginPage

Dec 19, 2010

How to set Request.IsAuthenticated to true when not using FormsAuthentication.RedirectFromLoginPage?

View 3 Replies

Run If(!User.IsAuthenticated) Or Access Profile.values In App_Code? C# .NET?

May 14, 2010

i'm trying to run a conditional statement in a class i'm placing in my App_Code folderthe condition is whether the person is logged in or not. I normally have two ways to do this in my masterpage and ASPX's

if (!User.IsAuthenticated) or if(Profile.username = "anonymous")

however neither of these things seem available to me in the .cs i'm making. anyone know what i'm missing? maybe a using namespace up top?

View 1 Replies

Security :: Httpcontext.current.user.identity.isauthenticated Always False?

Sep 7, 2010

I create two pages, the first one is the login page with user name and password textboxes - (not asp login control) , when clicking login button I check the login authentication, if it is true redirect to default page. in the default page if !IsCallBack then i check httpcontext.current.user.identity.isauthenticated

if it is false i redirect the user to the login page. but my problem is that the httpcontext.current.user.identity.isauthenticated is always false.

Below the section of authentication in web config

[code]....

View 5 Replies

Security :: HttpContext.Current.User.Identity.IsAuthenticated / Module Isn't Working

Jan 18, 2010

We have an SharePoint site no login (anonymous) with a search module using AJAX. Now the users complains that the module isn't working. When I check the code (not developed by me), I find that the code only runs if "HttpContext.Current.User.Identity.IsAuthenticated=true". Could that ever return true on an anonymous site?

View 1 Replies

Security :: User.Identity.IsAuthenticated Returns True But Session Has Expired

May 24, 2010

I have a page where, when the user has successfully logged in, I store some values in the session.

I then use these values to load an application list page. This page is automatically refreshed after 20.1 minutes, with the sessionstate timeout and forms timeout in web.config set to 20 minutes (with sliding expiration). This means, if the user does not use any page for more than 20 minutes, he is timed out.

My problem is that the User.Identity.IsAuthenticated sometimes returns true, when the session has expired.

Why is this happening, and how can I fix it?

View 3 Replies

Web Forms :: Sequence Order For Page.IsPostBack And User.Identity.IsAuthenticated?

Apr 22, 2010

What is the best sequence order for Page.IsPostBack and User.Identity.IsAuthenticated? From what I have search for, this comes up most common:

If Not Page.IsPostBack Then
If User.Identity.IsAuthenticated Then
~Some kind of code~
End If
End If

Is this considered "best practice" or can the two items - Page.IsPostBack and User.Identity.IsAuthenticated -be split into their own sections so the fuctions of these can be independent of each other?I am trying to troubleshoot a placeholder that disappears from a master page when a content page button is pressed to change the content pages active view (I have a multiview w/ 5 views inside of it).

View 2 Replies

Security :: IIS7 Recycle Results In Context.User.Identity.IsAuthenticated = False?

Nov 22, 2010

I need an app pool recycle to be completely transparent to the users of my web app. I use ASP.NET 3.5 MVC 1.

Currently, upon an IIS 7 App Pool recycle all users logged into my web app are kicked out and are required to log back in (Context.User.Identity.IsAuthenticated is set to false). I employ SQL State Server, I use forms authentication and both are configured to use cookies. I was under the impression that .NET and/or IIS handles authentication of cookies.

However, every time the app pool is recycled Context.User.Identity.IsAuthenticated is set to false my users are kicked out and are required to log back in. I can see that the session id remains the same throughout logins, I can also view this session information in the database/state server.

Logon method:

[Code]....

Custom Controller Attribute:

[Code]....

WebConfig:

[Code]....

View 1 Replies

Page.User.Identity.IsAuthenticated Returns Object Reference Not Set To Instance Of Object?

Dec 23, 2010

this works fine on my local site but as soon as i upload the site to my live server i get stem.NullReferenceException: Object reference not set to an instance of an object

on the first line of this:

if (!Page.User.Identity.IsAuthenticated)
{
pnlSignIn.Visible = true;
pnlSignOut.Visible = false;
}

View 1 Replies

If User.Identity.IsAuthenticated Then... Object Reference Not Set To An Instance Of An Object?

Jan 2, 2010

this problem is baffling me. I have a custom class that all my pages inherit from

Public Class Page : Inherits Page
Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Display Admin Controls (Buttons) '

[code]...

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved