Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesWhy is DNN expiring my authentication cookies when non-admin accesses ashx?Why is DNN expiring my authentication cookies when non-admin accesses ashx?
Previous
 
Next
New Post
5/8/2012 2:17 PM
 
I am seeing a really wierd issue that only happens with non-administration users.When the user logs in and accesses one page, they are logged out of the system. The page finishes loading as if they were logged in, but once they try any other actions (including refreshing the browser page) they are considered not logged in and presented with a login prompt.Opening up fiddler, I can see one of the responses from the server contains the following:=======================================Response sent 71 bytes of Cookie data: Set-Cookie: portalaliasid=; expires=Sat, 08-May-1982 17:26:06 GMT; path=/; HttpOnlyResponse sent 69 bytes of Cookie data: Set-Cookie: portalroles=; expires=Sat, 08-May-1982 17:26:06 GMT; path=/; HttpOnlyResponse sent 69 bytes of Cookie data: Set-Cookie: .DOTNETNUKE=; expires=Tue, 12-Oct-1999 04:00:00 GMT; path=/; HttpOnlyResponse sent 27 bytes of Cookie data: Set-Cookie: language=; path=/; HttpOnlyResponse sent 33 bytes of Cookie data: Set-Cookie: authentication=; path=/; HttpOnly=================================================This always seems to happen when I access my custom ashx web call. The code making this call is the following =============================================================== $('#lstStates').empty(); var selectedRegions = $('select[id*=lbxRegions]').val(); // Get the list of states for the selected regions $.ajax({ url: '/DesktopModules/MyModule/ashx/GetStatesForRegions.ashx', data: { regions: selectedRegions }, dataType: 'json', success: function (data) { if (IsArray(data)) { for (var state in data) { $('#lstStates').append(' '); } } } });=================================================================The code in the ashx.cs is============================================================= public class GetStatesForRegions : IHttpHandler { public bool IsReusable { get { return false; } } public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; // Get the list of region ids from the GET request string[] ids; string regionsArray = context.Request["regions[]"] ?? string.Empty; ids = regionsArray.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); using (var dbContext = new MyDataContext()) { string[] states; var query = dbContext.Schools.Where(x => x.PodRegionId != null); if (ids != null && ids.Length > 0) query = query.Where(x => ids.Contains(x.PodRegionId.ToString())); states = query.Select(x => x.xosAddress.State) .Distinct() .OrderBy(x => x) .ToArray(); context.Response.Write(JsonConvert.SerializeObject(states)); context.Response.End(); } } }=======================================To add to the mystery, when you access the ashx as a non-administrator DNN seems to return a 302 HTTP response, redirecting you to the same url again. That 302 response is what contains the cookie clearing data. The 2nd time it accesses the ashx (due to the redirect) the correct data is returned.Anyone have any insights as to why this is happening?
 
New Post
5/9/2012 6:29 AM
 
if your page is not a dnn page and there is no portal context, the cookie will be deleted for security reasons. provide a portal ID with your URL.

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesWhy is DNN expiring my authentication cookies when non-admin accesses ashx?Why is DNN expiring my authentication cookies when non-admin accesses ashx?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out