Solved

HttpContext.Current.User.Identity.Name empty in one HttpHandler but has a value in another

Posted on 2013-02-03
3
970 Views
Last Modified: 2013-02-15
I have two HttpHandlers. One intercepts for any pdf file request in the url, the other for an xml request. In pdf file handler I get the username from HttpContext.Current.User.Identity.Name but when a request is made for xml file HttpContext.Current.User.Identity.Name is always emtpy.

my relevant sections web.config are

<add verb="*" path="/calderdale/*.pdf" type="NES.HiLo.Security.CalderDaleAuthenticationHandler, NES.HiLo.Security" />
<add verb="GET" path="/Pallative/*.xml" type="NES.HiLo.Security.PallativeAuthenticationHandler, NES.HiLo.Security" />

<authentication mode="Forms">
   <forms name="KFCSAUTH" loginUrl="login.aspx" protection="All" 
          slidingExpiration="true" path="/" domain=".scot.nhs.uk" />
</authentication>
<authorization>
    <allow users="?" />
</authorization>
<system.webServer>
   <!--<validation validateIntegratedModeConfiguration="false" />-->
   <handlers>
      <add name="Pallative Handler" path="/Pallative/*.xml" verb="GET" 
           modules="IsapiModule" 
           scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" 
           resourceType="Unspecified" requireAccess="Script" 
           preCondition="classicMode,runtimeVersionv2.0,bitness32" />
      <add name="Calderdale Handler" path="/calderdale/*.pdf" verb="GET" 
           modules="IsapiModule" 
           scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" 
           resourceType="Unspecified" requireAccess="Script" 
           preCondition="classicMode,runtimeVersionv2.0,bitness32" />
       <!--<add name="Pallative Handler" path="Pallative/pallative_doc.html" 
                verb="GET" modules="IsapiModule" 
                scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" 
                resourceType="Unspecified" requireAccess="Script" 
                preCondition="classicMode,runtimeVersionv2.0,bitness32" />
   </handlers>
</system.webServer>

Open in new window

0
Comment
Question by:mmalik15
  • 2
3 Comments
 
LVL 11

Expert Comment

by:MajorBigDeal
ID: 38849143
Can you check HttpContext.Current.User.Identity.IsAuthenticated to see if that is the reason?  

http://stackoverflow.com/questions/7839567/why-does-httpcontext-current-user-identity-name-return-blank
0
 
LVL 11

Expert Comment

by:MajorBigDeal
ID: 38849148
Also, on the below thread the user reported that the form load event was firing twice and that in the second call the value was set but in the first call it was not.

http://www.visualwebgui.com/Developers/Forums/tabid/364/forumid/48/threadid/36589/scope/posts/Default.aspx
0
 
LVL 9

Accepted Solution

by:
darjimaulik earned 500 total points
ID: 38850305
<add verb="*" path="/calderdale/*.pdf" type="NES.HiLo.Security.CalderDaleAuthenticationHandler, NES.HiLo.Security" />
<add verb="GET" path="/Pallative/*.xml" type="NES.HiLo.Security.PallativeAuthenticationHandler, NES.HiLo.Security" />

Open in new window

Try to change the verb = "*" for XML.

Are you updating any details related to User login in the XML handler as that handler will be called in both the case.

Try to change the sequence of pdf and xml handler.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now