Solved

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

Posted on 2013-02-03
3
958 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
Comment Utility
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
Comment Utility
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
Comment Utility
<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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

11 Experts available now in Live!

Get 1:1 Help Now