?Accessing a ADO.NET Data Service from another ASP.NET MVC web application using forms authentication RRS feed

  • Question

    1. I have ADO.Net Data Service (.Net Framework 3.5 SP1) with authentication (Forms Authentication) enabled. When I browse the service in browser, it redirect me to login page. That is, it is working fine.
    2. I have a ASP.NET MVC 1.0 application (3 layered) that consumes the above services. Three layers are Presentation layer (ASP.NET MVC Framework), Business Logic Layer, Data Access Layer.
    3. ASP.NET MVC framework has its own forms authentication. And it is working fine.
    4. DAL consumes the ADO.NET Data Service. In DAL, I am trying to authenticate to data service. Followings are code samples.
    5. private void InitDB()
                  context = new CMSEntities(new Uri("http://localhost/CMSDataService/CMSDataService.svc/"));
                  context.SendingRequest += BeforeSendingRequest;
                  context.MergeOption = MergeOption.AppendOnly;
    6. static void BeforeSendingRequest(object sender, SendingRequestEventArgs e)
                  // Grab the identity that ASP.NET membership set up for us
                  ClientFormsIdentity aspNetIdentity =
                    Thread.CurrentPrincipal.Identity as ClientFormsIdentity;

                  // Grab the web request
                  HttpWebRequest wr = e.Request as HttpWebRequest;

                  // Copy the cookies
                  if (aspNetIdentity != null)
                      wr.CookieContainer = aspNetIdentity.AuthenticationCookies;
    7. But it gives error: Message="Error processing response's mime-type type 'text/html'.  The only supported mime-type is 'application/atom+xml'."
    8. What's going wrong? Am I in right path?

    Thanks in advance

    -- Mosharraf
    Saturday, May 23, 2009 12:13 PM

All replies

  • Hi,

    It sounds like the request is failing somewhere, and the response that is coming back is an unexpected html page.

    Can you use a tool like Fiddler to capture the request/responses that are being sent? There may be more than one due to the authentication.
    Matt Meehan, ADO.NET Data Services (Astoria)
    Tuesday, May 26, 2009 5:04 AM