473,385 Members | 1,570 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Strange HttpContext issue

Hello all

I've got a very weird situation I need help with. I'm building a
solution where I have custom components in a web content management
system using a web store library (API in DLLs). The CMS is using Forms
authentication to verify users when they log in. I log the user in
using the following code:

private bool AttemptLogon( string username, string password )
{
_errorMessage = "";
Customer customer = new Customer();
try
{
if (Customer.Login(username,password))
{

FormsAuthentication.SetAuthCookie(username,false,
"/boksala");

string redirecturl = (string)Session["oshopredirecturl"];
if (redirecturl != null && redirecturl != string.Empty)
{
Session.Abandon();
Response.Redirect( redirecturl );
}
else
{

Response.Redirect(HttpUrlBuilder.GetStoreHomePage( ).ToString());
}
return true;
}
else
{
_errorMessage = RM.GetString("ERROR_LOGIN_FAILED");
return false;
}
}
catch(AccountDisabledException)
{
_errorMessage = RM.GetString("ERROR_ACCOUNT_DISABLED");
}

return false;
}

After this is run, and a valid user is provided, the
HttpContext.Current.User.IsAuthenticated returns true and all is well.
When I then debug the 3rd party web store API DLL, everything turns
strange! The authentication type is all of a sudden Windows
Authentication, and IsAuthenticated returns false! How can this be? Is
there any possibility that there are two different HttpContexts? This
is within the same aspx page, and the context should therefore be the
same. I'm not sure if the 3rd Party API does something to change the
authentication mode all of a sudden, and I've searched for any
explanation in vain. Any ideas?

Thanks

Jun 2 '06 #1
1 1279
One good place to start is with the API documentation. Have a look to see
how it handles authentication in a server environment.

--

________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------

"Torfi" <to****@gmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
Hello all

I've got a very weird situation I need help with. I'm building a
solution where I have custom components in a web content management
system using a web store library (API in DLLs). The CMS is using Forms
authentication to verify users when they log in. I log the user in
using the following code:

private bool AttemptLogon( string username, string password )
{
_errorMessage = "";
Customer customer = new Customer();
try
{
if (Customer.Login(username,password))
{

FormsAuthentication.SetAuthCookie(username,false,
"/boksala");

string redirecturl = (string)Session["oshopredirecturl"];
if (redirecturl != null && redirecturl != string.Empty)
{
Session.Abandon();
Response.Redirect( redirecturl );
}
else
{

Response.Redirect(HttpUrlBuilder.GetStoreHomePage( ).ToString());
}
return true;
}
else
{
_errorMessage = RM.GetString("ERROR_LOGIN_FAILED");
return false;
}
}
catch(AccountDisabledException)
{
_errorMessage = RM.GetString("ERROR_ACCOUNT_DISABLED");
}

return false;
}

After this is run, and a valid user is provided, the
HttpContext.Current.User.IsAuthenticated returns true and all is well.
When I then debug the 3rd party web store API DLL, everything turns
strange! The authentication type is all of a sudden Windows
Authentication, and IsAuthenticated returns false! How can this be? Is
there any possibility that there are two different HttpContexts? This
is within the same aspx page, and the context should therefore be the
same. I'm not sure if the 3rd Party API does something to change the
authentication mode all of a sudden, and I've searched for any
explanation in vain. Any ideas?

Thanks

Jun 3 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mike | last post by:
I have been receiving this very strange 404 lately and was wondering if anyone else out there has had a similar problem. For some reason when users receive this error and they hit refresh the...
1
by: Sean Nolan | last post by:
I'm wondering if anyone has encountered something similar to the error I've pasted below. We get similar errors when someone hits a bad link etc., but the part I can't figure out here is where the...
5
by: Archer | last post by:
I was making a role-based authentication but it does't login with correct password. the HttpContext.Current.User recieved in Global.asax is always null. Request.IsAuthenticated is always false....
15
by: James Higgs | last post by:
For a long time, our product has had a "vanity URLs" feature where nice URLs are mapped to ASPX files in an IHttpModule implementation, using HttpContext.RewritePath(). This has worked beautifully...
3
by: asanford | last post by:
I want to create an ASP.NET web application that receives a form POST message, inspects the data, and reroutes the request to one of many different servers. I wrote an IHttpModule which...
5
by: Developer.Man4 | last post by:
when i try using HttpContext.Current.Server.MapPath(path) from a desktop application built using c# i get a System.NullReferenceException can anyone tell me why and what to do?? m using...
16
by: Victor | last post by:
I have a strange problem in my website. I configured my website to run under 2 worker processes. (web garden enabled). and I stored my user information in the current httpcontext(like...
1
by: jbitz | last post by:
Hi, This has got me really baffled. This has got me really baffled. When I run Dim url As String = HttpContext.Current.Request.Url.AbsolutePath.ToLower from Application_beginRequest in...
2
by: =?Utf-8?B?UGF1bCBCdXp6YSwgb2xkc3RlciB1c2luZyBuZXcg | last post by:
I recently implemented error processing on my .net website, where I send myself an email from global.asax on an application error. In the last two days I have gotten a "The file '/detail.aspx'...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.