Get IHttpHandler in WCF service

C#

    Sponsored Links

    Next

  • 1. Open diskpartition
    Something went wrong with my previous post, so this is the full question : Hello, in the past I used the CreateFile, ReadFile and WriteFile api to access a diskpartition directly (e.g. "\\.\c:") to read raw sectors. I was planning on converting some of those old c++ classes to c#. However using FileStream I get the following error : "Additional information: FileStream opent geen Win32-apparaten zoals schijfpartities en tapestations. Maak geen gebruik van \\.\ in het pad." which translates into "Additional information: FileStream doesn't open Win32-systems like diskpartitions and tapestations. Don't use \\.\ in the path." So I need to use another class but I can't find out which one. Or isn't there one and am I still stuck with the old win32 API which I need to access through P/Invoke? TIA Yves
  • 2. How do I convert from iso-8859-1 to utf-8 (bom)?
    I tried to convert a block of text from iso-8859-1 to utf-8 but all I got after the convertion is gibberish. =============================== FileStream fs = File.Open("text.txt", FileMode.Open, FileAccess.Read); byte[] b = new byte[length]; fs.Read(b, 0, length); b = Encoding.Convert(Encoding.GetEncoding(28591), Encoding.UTF8, b); return System.Text.Encoding.UTF8.GetString(b); =============================== When I skipped the convertion line ( b = Encoding.Convert ....) the text is legible but still in iso-8859-9 encoding. Does anyone know what I'm doing wrong, or know a better way of doing this? Thanks, Du
  • 3. C# Intellisense With VB Shared (Static) Routines / Objects
    Steve, Are you sure that your developers are using the classes correctly? In VB, the static methods appear on instance variables, while in C#, you must preface the call with the type name. I've done this before, and it works fine. The static methods appear fine when I type the typename and then hit "." -- - Nicholas Paldino [.NET/C# MVP] - XXXX@XXXXX.COM "Steve Hasselbach" < XXXX@XXXXX.COM > wrote in message news: XXXX@XXXXX.COM ... > Our developers use both C#.NET and VB.NET. We have several classes written in VB.NET that contain shared/static functions and objects. Our problem is the Intellisense in C# does not list any routines or objects that are declared as shared/static within the VB.NET components. The routines run fine, but no intellisense in C#. This has become very hard to work with large VB.NET classes from C#.NET, and we are forced to refer to project documentation for every routine and object. Is there a way to get this working?
  • 4. Attributes and constant expressions
    Hi there, I'm creating a class to be viewed in a property-grid control. I'm using the Browsable, Category, Description, etc. -Attributes to specify the display-behaviour of the class in the prop-grid Control. My problem is, I'd like to load the values for the DescriptionAttributes from a string resource, but the compiler keeps telling me, I have to use constant values for the Attributes. How can this be solved? Thanks in advance, Matthias
  • 5. Newbie to XML
    It's my first time when I use XML and it's not working. I have the following code. WindowsIdentity MyIdentity = WindowsIdentity.GetCurrent(); string IdentName = MyIdentity.Name; string suser = IdentName.ToString().Substring(4); XmlTextReader reader = null; reader = new XmlTextReader("f:\\intranet\\users.xml"); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (reader.Name == "name") // After this reader.ReadString() = "" ???? { string test = reader.ReadString(); // Here is not working if (test.ToUpper() == suser.ToUpper()) { string mylevel = reader.GetAttribute("level"); Label1.Text = mylevel; } } } } reader.Close(); And this is my xml <?xml version="1.0" encoding="utf-8" ?> <users> <name level='0' >ASPNET</name> </users> What's wrong with this code ???

Get IHttpHandler in WCF service

Postby QWxwaGFwYWdl » Sat, 24 May 2008 07:08:00 GMT

Hello,

I want to get the IHttpHandler from a svc service.
With old asmx webservices, I get it using 
WebServiceHandlerFactory.GetHandler .

How can I get IHttpHandler in WCF running in serviceHostingEnvironment : 
aspNetCompatibilityEnabled="true" ?

Thanks in advance for your help.

Re: Get IHttpHandler in WCF service

Postby Marc Gravell » Sat, 24 May 2008 07:32:21 GMT

OK; *why* do you want the handler? What do you want to do?

Most things you can do by looking at the WCF pipeline ("inspectors",
etc). Yes, cmopatibility mode is an option, but I wouldn't use it
unless I had to - WCF doesn't always run over http or via ASP.NET...

Marc

Re: Get IHttpHandler in WCF service

Postby QWxwaGFwYWdl » Sat, 24 May 2008 16:36:02 GMT

Marc,

I only want to get the Handler as I was doing in an old asmx webservice.

Re: Get IHttpHandler in WCF service

Postby Marc Gravell » Sat, 24 May 2008 16:46:40 GMT

> I only want to get the Handler as I was doing in an old asmx webservice.

Yes... but why; what do you want to do with the handler? The point is
that there may be different (but more than adequate) ways of doing
this with WCF. Quite simply, WCF isn't actually part of the ASP.NET
pipeline, and handlers are an ASP.NET feature. If you happen to be
running in ASP.NET, you *might* be able to get the handler (not sure)
via compatibility mode, but I would still consider this a hacky
solution, and it adds unnecessary overhead (the ASP.NET shims) to the
WCF stack.

So if you can tell me what you actually want to do, I might be able to
suggest an appropriate WCF way to do this...

Marc

Re: Get IHttpHandler in WCF service

Postby QWxwaGFwYWdl » Sat, 24 May 2008 19:58:01 GMT

I want to process the following code in WCF:

using System;
using System.Web;
using System.Web.UI;
using System.Web.Services.Protocols; 
using System.Web.SessionState; 

public class AspCompatWebServiceHandler : 
    System.Web.UI.Page, IHttpAsyncHandler, IRequiresSessionState
{ 
    protected override void OnInit(EventArgs e) 
    { 
        IHttpHandler handler =
            new WebServiceHandlerFactory ().GetHandler(
                this.Context,
                this.Context.Request.HttpMethod,
                this.Context.Request.FilePath,
                this.Context.Request.PhysicalPath);
        handler.ProcessRequest(this.Context);
        this.Context.ApplicationInstance.CompleteRequest();
    } 

    public IAsyncResult BeginProcessRequest(
        HttpContext context, AsyncCallback cb, object extraData) 
    { 
        return this.AspCompatBeginProcessRequest(
            context, cb, extraData); 
    } 

    public void EndProcessRequest(IAsyncResult result) 
    {
        this.AspCompatEndProcessRequest(result); 
    } 
}


In order for AspCompatWebServiceHandler to work its magic, it must be 
registered as the HTTP handler for ASMX files. You can register it using this 
web.config file: 
<configuration>
  <system.web>
    <httpHandlers>
      <add verb="*" path="*.asmx"
        type="AspCompatWebServiceHandler, __code" />
    </httpHandlers>
  </system.web>
</configuration>

Thanks for your help Marc.

Similar Threads:

1.AJAX enabled WCF Service Vs Standard WCF Service

Hi Guys,

In Visual Studio 2008 there is an new item template called something 
like "AJAX enabled" WCF Service along with just the standard WCF Service 
template.

Can anyone explain to me what the actual difference is between the two? 
I can see that the AJAX enabled service has a slightly different config 
file, but I'm unsure what actual difference this makes?

In particular, is the format of the data returned different when its 
AJAX enabled - if so, how is it different?

Many thanks in advance

Simon

2.Getting Error when Service account of WCF Service is a new account

Hi, I have WCF service and integrated with STS (WS-Federation). The Service 
exposes 5 endpoints Win, UNT and Federated Windows, Federated UNT and Mex 
endpoint.

My STS Service exposes 3 endpoints WIN, UNT and Mex.

I am getting error when I sent a request from a client to WCF Service 
Fed-Win/ Fed-Unt endpoints. But it is passing for the regular Win and Unt 
endpoints.

Error:
Test method AMUnitTest.SessionAMUnitTest.CreateSessionWithWindows threw 
exception:  System.ServiceModel.Security.SecurityNegotiationException: 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.  --->  
System.ServiceModel.FaultException: The request for security token has 
invalid or malformed elements..

After digging, I found that it is throwing that error due to the Service 
account of my WCF Service ( this Service account is the new account just 
created and it do not have any profile in the machine where my Service and 
STS are running.

If I change the the Service Account some other user (which is logged in once 
into the machine, then it is creating the profile in the machine) then I am 
able to send the requests to all endpoints including Fed-Win and Fed-Unt 
endpoints.

So here my question is, how can I give the service account of WCF Service to 
a new user and to hit the Fed-Win / Fed-End points successfully.

Please let me know is there any solution for this.
 
cheers,
Ravi

3.AJAX enabled WCF Service Vs Standard WCF Service

Hi Guys,

In Visual Studio 2008 there is an new item template called something 
like "AJAX enabled" WCF Service along with just the standard WCF Service 
template.

Can anyone explain to me what the actual difference is between the two? 
I can see that the AJAX enabled service has a slightly different config 
file, but I'm unsure what actual difference this makes?

In particular, is the format of the data returned different when its 
AJAX enabled - if so, how is it different?

Many thanks in advance

Simon

4.how to call wcf service from another wcf service or class libr

5.WCF client browsing the same WCF service hosting on multiple PC

Hi,

I would like to host A service on multiple PC and I want a client to
browse, enumerate or find each instances of the service on different
PC.

Would you like to give me a direction or how to implement it?

Regards,

Bandu

6. WCF in IIS : get IHttpHandler to process request

7. WCF : get IHttpHandler

8. Getting directory info in an IIS hosted WCF service



Return to C#

 

Who is online

Users browsing this forum: No registered users and 73 guest