The relative URI could not be generated because the 'uriString' parameter is an absolute URI

I created a simple WCF service hosted in a web farm. Now when I load the service in my browser sometimes using http://www.example.com/somefolder/file.svc I get the following error. If I hit F5 several times, the page will eventually come back up again.

Update 1: I noticed that even if I use the IP of a separate webserver to load the svc in the browser, I sometimes get the same error and sometimes it works.

A relative URI could not be generated because the 'uriString' parameter is an absolute URI. http://www.example.com/somefolder/file.svc

[UriFormatException: A relative URI could not be generated because the 'uriString' parameter is an absolute URI. http://www.example.com/somefolder/file.svc]
System.ServiceModel.Activation.ApplyHostConfigurationBehavior.ThrowIfAbsolute (the Uri the uri) +154
System.ServiceModel.Activation.ApplyHostConfigurationBehavior.FailActivationIfEndpointsHaveAbsoluteAddress (ServiceHostBase services) +128
System.ServiceModel. Activation.ApplyHostConfigurationBehavior.System.ServiceModel.Description.IServiceBehavior.Validate (ServiceDescription description, ServiceHostBase service) +65
System.ServiceModel.Description.DispatcherBuilder.ValidateDescription (ServiceDescription + ServiceHost1)
System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost (ServiceDescription description, ServiceHostBase serviceHost) +84
System.ServiceModel.ServiceHostBase.InitializeRuntime () +37
System.ServiceModel.ServiceHostBase.OnBeginOpen () +27
System.ServiceModel.ServiceHostBase.OnOpen (taym- TimeSpan out) +49
System.ServiceModel.Channels.CommunicationObject.Open (TimeSpan timeout) +261
System.ServiceModel.HostingManager.ActivateService (String normalizedVirtualPath) +121
System.ServiceModel.HostingManager.EnsureServiceAnormalized

[ServiceActivationException: Service /somefolder/file.svc cannot be activated due to a compile-time exception. Exception message: A relative URI could not be generated because the 'uriString' parameter is an absolute URI. http://www.example.com/somefolder/file.svc.]
System.ServiceModel.AsyncResult.End (result IAsyncResult) +11653822
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End (IAsyncResult result) +194
System.ServiceModel.Activation .HostedHttpRequestAsyncResult.ExecuteSynchronous (HttpApplication context, Boolean flowContext) +176
System.ServiceModel.Activation.HttpHandler.ProcessRequest (HttpContext context) +23
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute () +181 System.Web.HttpApplication.ExecuteStep (step IExecutionStep, Boolean & completed synchronously) +75

I'm not sure what is causing this. As I said, I just load the service. I also don't use URIs in my code. The webservice is hosted on three servers using IIS7.5 and points everything to a shared drive containing wcf files.

Here is a section from web.config:

<!-- Configuration For File.svc -->
    <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

        <services>
            <service behaviorConfiguration="WebFileService.FileBehavior" name="WebFileService.File">
                <endpoint address="http://www.example.com/somefolder/file.svc" binding="wsHttpBinding" contract="WebFileService.IFile" bindingConfiguration="WSHttpBinding_IFile">
                    <identity>
                        <dns value="localhost" />
                    </identity>
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="WebFileService.FileBehavior">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <bindings>
            <wsHttpBinding>
                <binding name="WSHttpBinding_IFile" closeTimeout="00:01:00" openTimeout="00:01:00"
                    receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
                    transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferPoolSize="524288" maxReceivedMessageSize="1000000"
                    messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                    allowCookies="false">
                    <readerQuotas maxDepth="32" maxStringContentLength="99999" maxArrayLength="999999"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
                        <message clientCredentialType="None" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true"/>
                    </security>
                </binding>
            </wsHttpBinding>
        </bindings>
    </system.serviceModel>

      

+3


source to share


1 answer


I had the same problem and fixed it by making the endpoint a relative address (I removed the address attribute value by making an empty string - address = "") on the endpoint node. My .svc is in the path called from the url, so an empty address is not a problem.



I also don't use the node id, but I have multipleSiteBindingsEnabled set to true.

0


source







All Articles