VS 2008 - Context.User.Identity.Name Is Empty
Oct 17, 2010
After setting the auth cookie using
FormsAuthentication.SetAuthCookie("myusername", False)
server.transfer("somepage.aspx") to open a web page.
Context.User.Identity.Name is found to be empty
But if I use
Response.Redirect("somepage.aspx")
Context.User.Identity.Name provides correct result.
I am aware of the differences between Response.Redirect and server.transfer. But exactly what is the reason behind this particular behaviour ?
View 1 Replies
Similar Messages:
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
Jun 13, 2010
To avoid going to the Databse to get the user Id, Id like to append userId to the Context.User.Idenity.name field. This way I can split the returned string to get the UserId without going to the database.
Where can I do this when using the login controls?
Is there some event handler where I can add:
FormsAuthentication.SetAuthCookie(NamePlusUserID, false);
View 1 Replies
Sep 30, 2010
When I am debugging an application in ASP.NET, after about ~5 minutes I get a NullRefEx coming from global.asax.cs regarding:
protected void Session_Start(Object sender, EventArgs e)
{
WindowsIdentity identity = null;
identity = (WindowsIdentity)(Context.User.Identity);
...
Context is Null at this point. I am a noob in ASP.NET with regards to Global.asax.cs. This code was written by another developer. EDIT: This is the code with HttpContext...
protected void Session_Start(Object sender, EventArgs e)
{
WindowsIdentity identity = null;
identity = (WindowsIdentity)(HttpContext.Current.User.Identity);
View 1 Replies
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
Mar 28, 2011
I'm using a custom ashx handler to handle a file upload. When run locally, the file uploads fine.When I use the same setup on the web server I get a "Index out of range" error.In firebug I see the binary contents of the file in the post data and the file name is also passed in the query string.Any one seen this before?I`m sure its something minor, but its driving me up the wall.
Request header:
Key Value
Request POST /Secured/UploadHandler.ashx? HTTP/1.1
Accept text/html, application/xhtml+xml, */*
Referer http://cms.webstreet.co.il/Secured/fileUpload.aspx
Accept-Language he-IL
User-Agent Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
Content-Type multipart/form-data; boundary=---------------------------7db13b13d1b12
Accept-Encoding gzip, deflate
[code]...
View 2 Replies
Feb 2, 2011
In IIS Manager center pane, there is an icon titled "Authentication" as follows: Clicking the icon, we get 3 items as follows: Right clicking the Anonymous Authentication and select edit, we have: Question: which one should I use? What is the difference?
View 3 Replies
Dec 23, 2010
I have implemented Forms authentication in an ASP.NET MVC 2 website
By using <%: Page.User.Identity.Name %> on the Site.Master page I can display the userid of the logged in user.
I would like to use this value and display other information about the user that is stored in a User table in a MsSQL database, like:
<%: GetFirstname(Page.User.Identity.Name) %>
View 2 Replies
Jan 30, 2011
get the below error. My application was working fine until I probably modified something, but don't know what.
Server Error in '/' Application.
Method is only supported if the user name parameter matches the user name in the current Windows Identity.
Description: An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Configuration.Provider.ProviderException: Method is only supported if the user name parameter matches the user name in the current Windows Identity.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ProviderException: Method is only supported if the user name parameter matches the user name in the current Windows Identity.]
System.Web.Security.WindowsTokenRoleProvider.GetCurrentWindowsIdentityAndCheckName(String userName) +2195661
System.Web.Security.WindowsTokenRoleProvider.GetCurrentTokenAndCheckName(String userName) +36
System.Web.Security.WindowsTokenRoleProvider.GetRolesForUser(String username) +61
System.Web.Security.RolePrincipal.IsInRole(String role) +182....
View 1 Replies
Oct 27, 2010
i want to use dataset , or any thing ... to display Sum * where user= user.identity.name(not use gridvew, or formview) because i have more then 100 columns . i m newbie. realy , 1 month, it not solve, sometime , i want to give up
View 3 Replies
Mar 2, 2010
I have created a web services (WCF) and i have a webmethod that return a string that string is a HTTPCONTEXT.USER.IDENTITY.USER unfortunately it does not return any value.
View 9 Replies
Oct 8, 2010
Error3Type 'LinqChatDataContext' is not defined.
i have above error whne woring with linq
View 3 Replies
Jun 28, 2011
In the IIS, it shows that the web app (i'm using) is using an application pool that uses NETWORK SERVICE account for identity. But when I debug/run my web app, User.Identity.Name shows that my windows user login instead. I checked my web.config file, and it does not have Impersonate enabled. In fact, I set it to false, and it still shows the same.
View 1 Replies
Mar 4, 2010
Is there a simple way to just retrieve the user's name, and not the Domain name, when using this function:
string quizTaker = Page.User.Identity.Name.ToString();
Right now it returns "DOMAIN_NAMEUserName"
I would like to just use isolate and use the user's name, without the Domain name.
View 2 Replies
Jun 9, 2010
i currently work on an asp.net mvc 2 project and noticed that inside an asp.net mvc view page i can get the user name authenticated via User.Identity.Name, but if i try to use the DsiplayFor method in order to display my model from a view user control, it just does not exist. Could i pass this parameter to my model using additional ViewData parameter that comes with DisplayFor html extension?
View 2 Replies
Jun 12, 2010
I need to create Unit Tests for an ASP.NET MVC 2.0 web site. The site uses Windows Authentication.I've been reading up on the necessity to mock the HTTP context for code that deals with the HttpContext. I feel like I'm starting to get a handle on the DI pattern as well. (Give the class an attribute of type IRepository and then pass in a Repository object when you instantiate the controller.)
What I don't understand, however, is the proper way to Mock the Windows Principal object available through User.Identity. Is this part of the HttpContext? have a link to an article that demonstrates this (or a recommendation for a book)?
View 2 Replies
Nov 15, 2010
I want to get the user specified in the app pool identity (which for us is a domain user). I want to get this info in Application_Start.
View 2 Replies
Feb 22, 2011
How can i check if dataset is emty some thing like follows
if dataset=emty then
msgbox("NO table")
else
....
End if
I am importing excel files from root folder, when file not there then message should apeear to avoid collapsing application.
Code:
ry
Dim strExcelConn As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ExcelConnection1").ToString()
Dim dbConn As New OleDbConnection(strExcelConn)
Dim strSQL As String
[code]...
View 9 Replies
Oct 7, 2010
what is the use formsAuthentication.user.identity
is it one of the property of page
View 1 Replies
Jul 30, 2010
I'm not talking about asp.net membership.
For each logged user I want to cache some properties like status or the number of friend requests, from the db.
I can create custom class which would do it but I thought it will be better to extend the existing User.Identity property. Something like this:
Label1.Text = User.Identity.Status;
View 2 Replies
Jun 2, 2010
I use FormsAuthentication.RedirectFromLoginPage(userName.Trim(), false); to set the User.Identity.Name field that I reference later. When I execute this line, the User.Identity object does not update at all; it contains whatever it was previously set to. All the documentation I see online says this should update my User.Identity object with the correct name, but I don't see that happening.
I have the web config set up properly with the following lines:
<authentication mode="Forms">
<forms name="formsauth" loginUrl="Login.aspx" protection="All" timeout="60">
</forms>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
View 1 Replies
Oct 20, 2010
am writing a web service in vb.net/asp.net 2, that needs user's name. It works fine when the url request is "www.mysite.com" but if any one has logged-in using "mysite.com" without a "www" and goes to the page that calls my web service, The HttpContext.Current.User.Identity.Name gives null. How can I resolve this problem?
View 2 Replies
Oct 5, 2010
For SqlDataSource I can configure the external source for the incoming paramater. For example it might be a QueryString, Session, Profile and so on. However I do not have an option to use User as a source.
I know that I could provide value for the parameter in Inserting,Selecting,Updating,Deleting events. But I do not think that this is an ellegant solution because I have some parameteres already definied in aspx file. I do not want to have parameters defined in two separate places. It makes mess.
So can I somehow define this parameter in .aspx file?
<SelectParameters>
<asp:QueryStringParameter DefaultValue="-1" Name="ID"
QueryStringField="ID" />
//User.Identity.Name goes here as a value for another parameter
</SelectParameters>
View 1 Replies
Mar 3, 2010
how do i add user.identity.name into db through sqldatasource in vb?
View 16 Replies
Sep 13, 2010
I m using MultiView and View Controls in my site. I have placed some DropDownlists in different Views containing data of YES/NO or some other data. I have put that data manually by Edit Items. But when i run the project my all DropDownList shows empty.
View 3 Replies