.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Getting SessionID from channel

Posted By:      Posted Date: August 24, 2010    Points: 0   Category :ASP.Net

I need to set ASP.NET_SessionId in order to dowload a file from server.

I use the following code

IContextChannel mychannel = (IContextChannel)myService;
using (OperationContextScope scope = new OperationContextScope(mychannel))
  res = myService.DoSomething();
  System.ServiceModel.Channels.MessageProperties messageProperties = System.ServiceModel.OperationContext.Current.IncomingMessageProperties;
  if (messageProperties.Count > 0)
    HttpResponseMessageProperty httpResponseMessageProperty = (HttpResponseMessageProperty)messageProperties[HttpResponseMessageProperty.Name];
  if (httpResponseMessageProperty != null)
  sessionCoookie = httpResponseMessageProperty.Headers[System.Net.HttpResponseHeader.SetCookie];

It works fine if I use basicHttpBinder.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;

But when I use windows authentication (basicHttpBinder.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;), there are 2 message responses.

The first one HTTP/1.1 401 Unauthorized with "Set-Cookie: ASP.NET_SessionId=sa34zv55sndjgq55fqzaw5ii; path=/; HttpOnly", I can see it in Fiddler and the second one with "WWW-Authenticate: Negotiate oYGgMIGdoAMKAQChCwYJKoZIgvcS

View Complete Post

More Related Resource Links

{ End Bracket }: Tune in to Channel 9


If you fly United Airlines, you can hear what's going on in the cockpit by turning the radio dial to Channel 9. Now if you want to get inside the head of Microsoft you can tune to Channel 9 on the MSDN Web site (see http://channel9.

MSDN Magazine September 2004

Secure It: WS-Security and Remoting Channel Sinks Give Message-Level Security to Your SOAP Packets


As more organizations adopt XML-based Web Services, the need for message-level security has become evident. WS-Security, now supported in the Microsoft .NET Framework, addresses this need. Using the WS-Security framework, developers can implement channel sinks to intercept Remoting messages as they pass through the .NET Remoting infrastructure. The sink can read the message, change it, and pass it along. During this process, the message can be signed for added security. This article explains how to implement a Remoting channel sink that will modify the Remoting message by including a UserName token in the header, then sign the body using the token.

Neeraj Srivastava

MSDN Magazine November 2003

.NET Remoting: Secure Your .NET Remoting Traffic by Writing an Asymmetric Encryption Channel Sink


As .NET Remoting gains popularity in the enterprise space, it must meet business demands for trustworthy computing. Remoting traffic can be secured when objects are hosted in IIS, but when they aren't hosted in IIS, custom security solutions can be developed to secure them. This article provides an in-depth look at writing channel sinks for .NET. It also details the flow of data through custom channel sinks and explains the kinds of manipulations that can be performed on that data.

Stephen Toub

MSDN Magazine June 2003

Hands-On Lab: Building Solutions with Access 2010 (Channel 9)

The objectives of this Hands-On Lab are to acquaint you with the new developer related features of Access 2010 with a keen emphasis on understanding the differences between developing database objects that will work in a Web database versus objects that work only in a client database.

Microsoft SharePoint 2010 Developer Training Course (Channel 9)

SharePoint 2010 provides a platform for developers to rapidly build solutions using familiar tools while leveraging a rich set of out-of-the-box features. Visual Studio 2010 and SharePoint Designer 2010 make developers even more productive. Find videos and presentations here to help you get started.

Download: SharePoint 2010 Developer Presentations for Channel 9

Download all of the PowerPoint presentations used in the SharePoint 2010 Learning Course on Channel 9.

parsing weather channel xml file using linq

 Hi I never used linq before and i'm having trouble parsing the xml file at  http://xoap.weather.com/search/search?where=" + strCityName.ToString(); I used to use a dataset but since trying to change my site to mvc, i thought i would use linq to xml, but after 2 days have still not found success. i have a class called: public class WeatherCityBLLModel { public string loc { get; set; } public string loc_id { get; set; } } and then a class called public class WeatherCityDALModel { public static List<WeatherCityBLLModel> GetLocation(string strCityName) { XDocument doc = XDocument.Load("http://xoap.weather.com/search/search?where=" + strCityName.ToString()) return doc; <<< Does not work } } How do i get the data from xoap.weather and pass it to my controller Any help appreciatedGeorge        

InteropBitmap, GDI bitmaps, and the alpha channel

Hey, After having successfully used InteropBitmap to render Windows Forms bitmaps in WPF scenes, I recently tried the same sort of thing using plain old GDI bitmaps, and I got surprising results.  So I am just doing something like: CBitmap gdiBitmap;gdiBitmap.CreateCompatibleBitmap( (CDC*) &dc, rClient.Width(), rClient.Height() );    and then I select it into a DC and make some GDI calls to fill it, draw a FrameRect, and draw some text.  After that, I do the normal dance to get the bitmap out of the DC, make a BitmapSource from it, and assign that to the Source property of the WPF Image in my scene: CBitmap * resbmp = dcOff.SelectObject( pOldBitmap );   HBITMAP hbmp = (HBITMAP) resbmp->GetSafeHandle();     BitmapSource ^bmpSource = CreateBitmapSourceFromHBitmap( (System::IntPtr) hbmp,       IntPtr::Zero, Int32Rect::Empty, BitmapSizeOptions::FromEmptyOptions() );   InteropBitmap ^ibmp = static_cast<InteropBitmap^>( bmpSource );     m_WPFImage->Source = ibmp;    When I do the above, the bitmap does not display *at all*.  After making some other calls to get the actual bits for the GDI bitmap, I can see that all of the alpha values are 0.  So what I'm getting is a bitmap that is completely transparent, and that is why InteropBitmap displays nothing.  The only way I have found to work around this is to pass the bitmap through GDI+ before creati

Need suggestion's and guidelines for designing and creating WCF client channel pool

  What factor's should be considered for creating a WCF client channel pool? 1)Whether it is advisable to create a pool of pre-opened channel's?or create a new channel as an when needed?which one is expensive operation? 2)what should be the pool size? 3)how pool will support if concurrent request's are coming which use different binding's? 4)what should be channel lifetime? 5)If all the connection's in the pool are busy,whether we should wait till the free channel's are available in the pool or create new one's which is expensive?which one is better? if anybody is able to provide some usefull links it will be helpfull.

What is the Regex pattern of SessionId

Hi asp.net 4.0 I wonder what the Regex pattern for session id is?

PollingDuplexHttpBinding Client Channel Faults unexpectedly after few seconds

Hello, i have a Silverlight 4 application which communicates using Http Polling Duplex to an IIS 7, .NET 4 WCF Service (actually two of them, in the same app). I am obviously taking advantage of the callback features provided by this type of solution. Setup has been performed by following these documents: Service setup: http://msdn.microsoft.com/en-us/library/cc645027%28v=VS.95%29.aspx Silverlight setup: http://msdn.microsoft.com/en-us/library/ee844557%28v=VS.95%29.aspx All has been working fine until yesterday, when i went on upgrading the Silverlight Tools for VS2010 to version 10.0.30319.352 which has also upgraded my Silverlight runtime to 4.0.50826.0 . Running my app now, after few seconds from the first call to the services, the client inner-channel faulted event fires on both proxies without an apparent motivation (exception, user interaction, etc.). What i have been able to notice, by analyzing connections with Fiddler, is that as soon as the open connection to the service which holds a callback channel receives a response, the client-side proxies fail. I'll try to show how the HTTP connections appear to behave: Call to the first service, callback channel retreived, immediate response 200 OK, no content Call to the second service, business logic performed, immediate response 200 OK, no content Call to the first service, no response for a few seconds, response 200 OK

Problem with IPC Channel "Port is busy: All pipe instances are busy"

Hi all. Sometimes, some of our remote objects when invoked throw an exception "Port is busy: All pipe instances are busy". Putting the code in a while(true) loop and catching the exception, after some loops everything goes fine. Does anyone know the meaning of that exception? I've been googling a lot but found no clue.   Thanks, regards Cristian Mori

Could not create SSL/TLS secure channel

I have a web service which calls into another web service. My web service allows anonymous access and the application pool runs under the "Local System" identity. I get the following error when my web service calls another web service which requires a cert for SSL:Could not create SSL/TLS secure channelI enabled a diagnostic trace, the end of which says:System.Net Information: 0 : [4168] SecureChannel#16871348 - Certificate is of type X509Certificate2 and contains the private key.System.Net Information: 0 : [4168] AcquireCredentialsHandle(package = Microsoft Unified Security Protocol Provider, intent  = Outbound, scc     = System.Net.SecureCredential)System.Net Error: 0 : [4168] AcquireCredentialsHandle() failed with error 0X8009030D.System.Net Information: 0 : [4168] AcquireCredentialsHandle(package = Microsoft Unified Security Protocol Provider, intent  = Outbound, scc     = System.Net.SecureCredential)System.Net Error: 0 : [4168] AcquireCredentialsHandle() failed with error 0X8009030D.System.Net.Sockets Verbose: 0 : [2928] Socket#13716631::Dispose()System.Net Error: 0 : [2928] Exception in the HttpWebRequest#19726116:: - The request was aborted: Could not create SSL/TLS secure channel.System.Net Error: 0 : [2928] Exception in the HttpWebRequest#19726116::EndGetResponse - The request was aborted: Could not create SSL/TLS secur

sessionID in some search engines coming in lower case (s( - bombing out

Is it possible to ignore case on the sessionID?  Is it useful/secure to do so?  I have a bothersome search engine hitting my site with session id's that have a lower case "s" in the ID, so it looks like - (s( -  at the beginning of the id, rather than - (S( -   It's filling up my error handling database with page not found because of it!  Does anyone have any good suggestions on how I might fix this?  Thanks bunches!

Secure channel cannot be opened because security negotiation with the remote endpoint has failed

Please help me to pinpoint what's wrong with the configurations. CoreClient client = new CoreClient(); client.ClientCredentials.UserName.UserName = "test"; client.ClientCredentials.UserName.Password = "test"; string msg = client.SayHello(); //==== ERROR Happens here Error message: Secure channel cannot be opened because security negotiation with the remote endpoint has failed. This may be due to absent or incorrectly specified EndpointIdentity in the EndpointAddress used to create the channel. Please verify the EndpointIdentity specified or implied by the EndpointAddress correctly identifies the remote endpoint. Configurations: Host: <behaviors> <serviceBehaviors> <behavior name="DefaultBehavior"> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="false"/> <serviceCredentials> <serviceCertificate findValue="MyServerCert" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My"/> <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Promotion.Services.UsernameValidator, LibraryIIS" /> </serviceCredentials> </behavior>

CLR type reflection when creating a channel using the ChannelFactory

In the Xsd that represents our canonical model, a complex type has various choices (several xsd:elements within xsd:choice) – i.e. the property when deserialized into C# has several XmlElement attributes decorated above it….

[System.Xml.Serialization.XmlElementAttribute("exampleRequest1", typeof(ExampleRequest1))]

[System.Xml.Serialization.XmlElementAttribute("exampleRequest1", typeof(ExampleRequest2))]

[System.Xml.Serialization.XmlElementAttribute("exampleRequest1", typeof(ExampleRequest200))]

[System.Xml.Serialization.XmlElementAttribute("exampleRequest1", typeof(ExampleRequest201))]

SessionID is coming in with lowercase 's'


Normally, when my server gets an invalid sessionID on the url it rewrites it.  However (several?) search engine(s) are sending requests to my server with a lower case in the session number, where there is normally an upper case S.  So for example

(s(vou3fq454gk3fbrncrmk1bmj)) will not just rewrite the sessionID and keep going, but

(S(vou3fq454gk3fbrncrmk1bmj)) WILL rewrite the sessionID and keep going without an error.

This is filling up my database and making it hard for me to use it effectively, plus, I would just like it to work.

Is there any way for it is not care if that first '(s(' is lower case?  Or is there a way for IIS to cope with this in an efficient manner?

Thanks for any suggestions.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend