locked
Sync Framwework 3.0 (June 2010)- Security Exception RRS feed

  • Question

  • Hello:

    I'm trying to run the desktop Silverlight application available in the "Samples overview" section and experiencing the following exception when I run the Silverlight applicaiton from VS.NET 2010.

    Synchronization failed: System.Security.SecurityException ---> System.Security.SecurityException: Security error.
       at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
       at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
       at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)
       --- End of inner exception stack trace ---
       at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
       at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
       at Microsoft.Synchronization.ClientServices.HttpCacheRequestHandler.OnDownloadGetResponseCompleted(IAsyncResult asyncResult)

    The List Service is deployed in IIS 7 (Windows 7).  The required permission has been setup for AUTHORITY\NETWORK SERVICE for the Login name (in IIS and SQL Express Database)

    I have the following clientaccesspolicy.xml added in the IIS root (C:\inetpub\wwwroot) and still unable to solve this. Please help!!

    <?xml version="1.0" encoding="utf-8"?>

    <access-policy>

      <cross-domain-access>

    <!--Enables Silverlight 3 all methods functionality-->

        <policy>

          <allow-from http-methods="*">     

            <domain uri="*"/>

          </allow-from>     

          <grant-to>     

            <resource path="/api" include-subpaths="true"/>

          </grant-to>     

        </policy>

    <!--Enables Silverlight 2 clients to continue to work normally -->

        <policy>

          <allow-from >     

            <domain uri="*"/>

          </allow-from>     

          <grant-to>     

            <resource path="/api" include-subpaths="true"/>

          </grant-to>      

        </policy>

      </cross-domain-access>

    </access-policy>

     

    Friday, August 20, 2010 8:09 PM

Answers

  • - When I browse the service directly from IIS, it returns a message "Method Not allowed".
    This is normal. Your browser sends a basic unparameterized GET request to the base URI but the webservice expects mostly POST requests. Please refer to the SyncFx 3.0 docs, page "OData Sync: HTTP".

    - I have even tried hosting the client application (\samples\SLSample\ListsSample\ListsSampleSite) in IIS. Now, it asks me to enter the user name. When I do so (ex: test), it throws an exception stating "System.Net. WebException: The remote server returned an error: Not found".

    Unfortunatly this error doesn't tell anything about the underlying reason. If the problem remains after fixing your clientaccesspolicy.xml (see above post) you will have to debug it by evaulating the HTTP traffic. Also make sure to set ISyncServiceConfiguration.UseVerboseErrors = true in your SyncService.

    • Marked as answer by arasheed Tuesday, August 24, 2010 4:00 PM
    Monday, August 23, 2010 6:53 AM
  • Is Capture Traffic selected on Fiddler?  You can check for this under the File menu. 

    You can also try to Debug the List Service to figure out where the WebException is being thrown.  To do this, on Visual Studio go to Debug -> Attach To Process (make sure Show processes in al sessions is checked) and select w3wp.exe, which is the IIS process. 

    Then on Debug->Exceptions make sure Common Runtime Language Exceptions Thrown is checked.

    Then retry the attempt to login.  You should be able to see the debug stack trace when the exception is hit.

     

     


    Maria del Mar Alvarez Rohena Microsoft Sync Framework
    • Marked as answer by arasheed Tuesday, August 24, 2010 4:00 PM
    Monday, August 23, 2010 11:39 PM
  • Thank you very much everyone. I'm able to finally fix this issue with all your feedback. The issue was that Windows XP requires ASP.NET user permission to access the Database, and isolated storage. I'm able to launch the application with one caveat. The "My Tags" tab is always empty. I would expect this to be populated from Database. Please advice.
    • Marked as answer by arasheed Thursday, August 26, 2010 5:13 PM
    Tuesday, August 24, 2010 2:41 PM
  • one caveat. The "My Tags" tab is always empty. I would expect this to be populated from Database. Please advice.
    Once you add some lists and tag those you will see that "My Tags" becomes to live, too.
    • Marked as answer by arasheed Wednesday, August 25, 2010 1:31 PM
    Wednesday, August 25, 2010 6:17 AM

All replies

  • Did you use fiddler to try to sniff the network traffic between the browser and service? This will tell us which request is failing.


    Maheshwar Jayaraman - http://blogs.msdn.com/mahjayar
    Friday, August 20, 2010 8:18 PM
  • Thanks Mahesjwar. I just see one request to http://localhost/clientaccesspolicy.xml which returns status code (304 - not modified). I do not see any calls to http://localhost/ListService/DefaultScopeSyncService.SVC/.

    - When I browse the service directly from IIS, it returns a message "Method Not allowed".

    - I have even tried hosting the client application (\samples\SLSample\ListsSample\ListsSampleSite) in IIS. Now, it asks me to enter the user name. When I do so (ex: test), it throws an exception stating "System.Net. WebException: The remote server returned an error: Not found".

    - When I run the Silverlight client application from VS.NET, it does not promt the login screen. It simply throws the security exception  I reported earlier at the bottom of the screen.

    - My IIS App pool is configured to use .NET 4.0 (32 compatibility enabled)

    - Please note I have already followed the fix per: http://social.microsoft.com/Forums/en-US/synclab/thread/cd366786-5aac-4396-adba-00d6c8af0652

    I'm not sure what I'm missing here. Please help!!

    Saturday, August 21, 2010 2:13 PM
  • Your original problem, the security exception, is a result from your clientaccesspolicy.xml - in your version you allow access to /api but the webservice lives at another URI. Here is a more general clientaccesspolicy.xml which is just fine for a developer's workstation:

    <?xml version="1.0" encoding="utf-8"?>
    <access-policy>
     <cross-domain-access>
      <policy>
       <allow-from http-request-headers="*">
        <domain uri="*"/>
       </allow-from>
       <grant-to>
        <resource path="/" include-subpaths="true"/>
       </grant-to>
      </policy>
     </cross-domain-access>
    </access-policy>
    

    • Proposed as answer by M.Bi Monday, August 23, 2010 6:53 AM
    Monday, August 23, 2010 6:45 AM
  • - When I browse the service directly from IIS, it returns a message "Method Not allowed".
    This is normal. Your browser sends a basic unparameterized GET request to the base URI but the webservice expects mostly POST requests. Please refer to the SyncFx 3.0 docs, page "OData Sync: HTTP".

    - I have even tried hosting the client application (\samples\SLSample\ListsSample\ListsSampleSite) in IIS. Now, it asks me to enter the user name. When I do so (ex: test), it throws an exception stating "System.Net. WebException: The remote server returned an error: Not found".

    Unfortunatly this error doesn't tell anything about the underlying reason. If the problem remains after fixing your clientaccesspolicy.xml (see above post) you will have to debug it by evaulating the HTTP traffic. Also make sure to set ISyncServiceConfiguration.UseVerboseErrors = true in your SyncService.

    • Marked as answer by arasheed Tuesday, August 24, 2010 4:00 PM
    Monday, August 23, 2010 6:53 AM
  • Thanks Bi. This fixed my security exception but the other issue is still open. The configuration is already ISyncServiceConfiguration.UseVerboseErrors = true  

    I tried tracing the HTTP traffic using HTTP analyzer and observe the following:

    As soon as I enter the user name there is a call to http://localhost/ListService/login.ashx?username=Rasheed . The http traffic at this stage "Request is not completed.  Waiting"

    At this point, I'm displayed with an error

    The Following error occurred when attempting to logon:

     "System.Net. WebException: The remote server returned an error: Not found

    I don't see anything in the HTTP traffic. Please advice.

    Rasheed

    Monday, August 23, 2010 5:11 PM
  • You should also change your IIS App Pool to the DefaultAppPool with .NET 2.0 and Pipeline mode: Integrated
    Maria del Mar Alvarez Rohena Microsoft Sync Framework
    Monday, August 23, 2010 10:28 PM
  • Thanks but the problem still remains the same. I have even repeated these steps in a Windows XP box. It return the same exact error when I attempt to logon.

    The Following error occurred when attempting to logon:

     "System.Net. WebException: The remote server returned an error: Not found

    I have a demo setup tomorrow and I'm exhausted :(

    Monday, August 23, 2010 11:27 PM
  • Is Capture Traffic selected on Fiddler?  You can check for this under the File menu. 

    You can also try to Debug the List Service to figure out where the WebException is being thrown.  To do this, on Visual Studio go to Debug -> Attach To Process (make sure Show processes in al sessions is checked) and select w3wp.exe, which is the IIS process. 

    Then on Debug->Exceptions make sure Common Runtime Language Exceptions Thrown is checked.

    Then retry the attempt to login.  You should be able to see the debug stack trace when the exception is hit.

     

     


    Maria del Mar Alvarez Rohena Microsoft Sync Framework
    • Marked as answer by arasheed Tuesday, August 24, 2010 4:00 PM
    Monday, August 23, 2010 11:39 PM
  • Thank you very much everyone. I'm able to finally fix this issue with all your feedback. The issue was that Windows XP requires ASP.NET user permission to access the Database, and isolated storage. I'm able to launch the application with one caveat. The "My Tags" tab is always empty. I would expect this to be populated from Database. Please advice.
    • Marked as answer by arasheed Thursday, August 26, 2010 5:13 PM
    Tuesday, August 24, 2010 2:41 PM
  • one caveat. The "My Tags" tab is always empty. I would expect this to be populated from Database. Please advice.
    Once you add some lists and tag those you will see that "My Tags" becomes to live, too.
    • Marked as answer by arasheed Wednesday, August 25, 2010 1:31 PM
    Wednesday, August 25, 2010 6:17 AM
  • I followed the ListService example which comes with MSF 4.0 and created a simple service and hosted it on my local IIS 7.0. Everything works fine. When I try to deploy the same project on our deployment server (Windows Server 2008 Enterprise Edition) I am getting the following exception: [System.Net.WebException] = {System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound.
       at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
       at Sys...
    I have added the crossdomain.xml and clientaccesspolicy.xml files to the service. Still I getting the same exception. 
    Wednesday, August 24, 2011 10:43 PM
  • user fiddler to sniff the traffic and see the underlying error.
    Friday, August 26, 2011 12:52 AM