Before hosting WCF Restful Services on IIS. I was getting response from server in my android application but now I have hosted my services on IIS but getting an error message of REQUEST ERROR. I don't know what's went wrong. can someone please sort out my problem. Thanks in Advance
Before Hosting on IIS
the above picture is before hosting the service on IIS. and the yellow highlighted text is param and the JSON is the response which is corresponding to that param.
After Hosting on IIS
I don't know why I'm getting this error. what went wrong and how to fix that. now im trying to retrieving data correspond to that param but getting an error message.
"SERVER LOG after includeexceptiondetailInfaults attribute value to true"
I'ms sure that database is causing the error and you can view the picture of server log below
The database was causing an error. I have found the solution. what we need to do? We need to add a login to SQL Server for IIS APPPOOL\ASP.NET v4.0 and grant permissions to the database.
In SQL Server Management, under the server, expand Security, then right click the Logins and select "New Login...".
In the New Login dialog, enter the app pool as the login name and click "OK"
now right click the login, select properties and then click on the User Mapping Option. Click the appropriate DATABASE and check the properties roles. And we are done :).
hope you good luck. Thanks
Possible solutions would be,
(i)Just ensure all your property are public.
(ii)To So see more details about the issue, you need to includeexceptiondetailInfaults attribute to true in servicedebug tag.
<servicebehaviors>
<behavior name="myServiceBehavior">
<servicedebug includeexceptiondetailinfaults="true" />
</behavior>
</servicebehaviors>
(iii)Remove the Enum types (or use their suggested work-around and use a wrapper around the enum properties) and this should go away.
(iv)Copy the connection strings from the class library app.config to the web project web.config If you are using a class library and a web project,
After hosting on iis
Request error occurred in iis
The server encountered on request error see server logs for more details
Solution
In your sql server change window authentic to sql authentic with username and password
and change on connection string
After changing these step and refresh the iis and
Your problem is solved
Related
I am using IIS7.5, .net 4.0. I am working locally.
I have installed Application Request Routing, Web Farm Framework, WebDeploy and UrlRewrite to set up a reverse proxy. This works fine for the most part.
I have two websites:
DefaultWebSite (port 80, app pool: Default App Pool (.net 4)) and
Target (port 8085, app pool: TargetAppPool(my identity, .net 4)).
I have a rewrite rule on DefaultWebSite (created as directed on IIS.net) which redirects all localhost (port 80) traffic to localhost:8085 just as detailed in the above link. This works fine for most document types (.aspx, .xap, .htm, .ico) but a request to MyService.svc fails. It returns a 404.
To be clear:
When I paste localhost:8085/MyService.svc into a browser I get the requested WCF page.
When I paste localhost/MyService.svc into a browser I get a 404.
When I paste localhost:8085/MyIcon.ico into a browser I get the requested resource.
When I paste localhost/MyIcon.ico into a browser I get the requested resource.
.svc is the only document type that I've found that returns a 404.
I've got two pieces of info that might be of relevance.
App Pools. When I change the DefaultWebSite's app pool to TargetAppPool then the 404 becomes a 500 ("Failed to map the path '/'"). All other requests are successful when this change is made. Not sure if this relevant or not.
FREB (Failed Request Tracing) Log. I found a page (http://blogs.msdn.com/b/asiatech/archive/2011/08/25/return-404-4-not-found-when-url-rewrite.aspx) which details the steps in a FREB log when a URL rewrite is more successful than mine (it fails later on). I've not been able to find out how to generate a FREB log for a successful rewrite (if that's possible) so I can only compare my FREB log to the one on that blog. I can see that their step 21 (URL_CHANGED) in my FREB log but not 22 (URL_REWRITE_END). I've not got enough experience with these logs to notice anything more significant than that (suggestions welcomed).
My main question is: does anyone know why just URLs requesting .svc resources are not being rewritten?
A secondary question is: does anyone know how to generate a FREB log for successful request (if it's even possible)?
Thanks
Update:
I have changed the architecture to try to get more info.
I have moved the Target website to a different PC on which I have installed Microsoft Network Monitor to capture the incoming traffic.
Before I changed the url-rewrite rule to point at this new website I got the correct response when I made a request to MyService.svc on the new PC. Fine.
As soon as I changed the rewrite rule to route the request to the new Target website then it responds as before (404). I have made both POST and GET requests. There is no sign of any of the requests in the Network Monitor log (all other calls -200, 404 or otherwise- appear in this log).
This leads me to think that there is something incompatible with url-rewrites and *.svc requests. I tried making a request to MyService.asmx (having created this file) and it correctly returned a page, so it is limited to *.svc. Any ideas?
The solution to this is in the config file of the Target web site.
In web.config (in the Target application) there is a section which read:
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>.
I changed this to read:
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />.
Credit must go to http://forums.iis.net/post/1956671.aspx for this (although s/he claims it is the proxy's config which needs to be changed, but I found it be the Target app, not the proxy server).
If you still can't get it running, make sure you don't have the WCF handlers on the website which acts as the reverse proxy.
I disabled this by adding this web.config of the reverse proxy:
<system.webServer>
...
<handlers>
<remove name="svc-ISAPI-4.0_64bit" />
<remove name="svc-ISAPI-4.0_32bit" />
<remove name="svc-Integrated-4.0" />
</handlers>
</system.webServer>
Because the rewrite appears to work for all resources except when the extension is .svc I would say this would be the area to concentrate on.
I would imagine that the rewrite rules are matching your other resources, but not your service, and because these are usually regular expressions (which are often complicated) I would say it would be worth testing any rules you find with your urls. Details of how to find the regular expressions for an UrlRewrite can be found here.
It is also probably also worth looking at any outbound rules with the same mindset.
When I run the "Getting Started" C# project of DESIRE2LEARN, I always get
The remote server returned an error: (403) Forbidden.
I don't provide values for UserId and UserKey fields for "Get Version" method, I only set Host, AppId, AppKey values for the new server, but it is not working still.
Then, I thought this could be related to wrong port#. I set it 443, but do not know what it is exactly. I set the port# wrong for D2L test-server in the working project file, and I got a different error:
"Unable to connect to the remote server".
So, I do not think it is about port#. My guess is that this is about API-related permission issue in the server. Do you think that the administrator need to change the settings in the server accordingly, so that access through API could be possible? Have you ever needed to configure the server for allowing access through API?
If you're retrieving a 403 (No Permission) error, it seems unlikely that your LMS has all support for the Valence Extensibility turned off (as it's likely that the API service layer itself is returning this error). It could be possible that the AppID/AppKey credentials that you're using are not recognized by your LMS. I suggest you open an issue with the Valence issue tracker, and work through the issue there. They may want your LMS admins to open a customer support ticket with Desire2Learn, in order to investigate the configuration of your LMS to ensure everything is properly set up.
Can anyone tell me why I get this error when I try to add my service?
Error: Cannot obtain Metadata from http://myserver/myapp. If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455. WS-Metadata Exchange Error URI: http://myserver/myapp Metadata contains a reference that cannot be resolved: 'http://myserver/myapp'. The remote server returned an unexpected response: (405) Method Not Allowed.
The remote server returned an error: (405) Method Not Allowed.HTTP GET Error URI: http://myserver/myapp There was an error downloading 'http://myserver/myapp'. The request failed with HTTP status 403: Forbidden.
Update: I have the following endpoint already,
<endpoint address="mex"
binding="mexHttpBinding"
name="Metadata"
contract="IMetadataExchange" />
I also have the service behaviors set:
<serviceBehaviors>
<behavior name="myBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
I had this issue, turns out that when I renamed the .svc file a reference to it hadn't been renamed from Service1.svc. Run a project wide search and replace .Service1 with your new name.
<%# ServiceHost Language="C#" Debug="true" Service="MyNamespace.Service1" CodeBehind="MyRenamedService.svc.cs" %>
Service="MyNamespace.Service1" should read Service="MyNamespace.MyRenamedService"
This can also happen when you try to return a custom class object from one of the functions and that function doesn't have the [DataContract] attribute on the class declaration. WCF cant figure out what type your returning so it throws the standard message.
[Serializable]
[DataContract]
public class ServiceResult
{
....
}
I figured it out. I was using an absolute path on one of my endpoints and I had more than one. I changed it to a relative path and then everything worked.
Also, this can happen if your service isn't running and may have nothing to do with metadata. If you have a ConfigurationErrorsException then you will see this result as well.
I also got it when trying to save configuration changes to the project and then it told me to save/overwrite/ignore, etc. It ended up adding a project subtype of "designer" and once I removed that it went back to working properly.
Some times there isn't anything to be done with metadata or the settings; instead we may simply use 127.0.0.1 instead of http:\localhost\
If adding the metadata endpoints is not your issue. Check further in the error message details. I had a missing library; "Could not load file or assembly *".
I needed to change the reference to Copy Local = True
I'm new to WCF and just got a project handed to me with WCF services inside.
I was having similar issues with using WCF Test Client in VS2010 on Win7. After trying all the config changes in this article and others I was still getting similar errors.
So I gave up and started reading up on WCF. Here I found that VS should be launched as administrator. Here's the article: Getting Started Tutorial WCF
Turns out I have to launch VS2010 with 'Run as Administrator' checked. This fixed the issue and I was able to test WCF services in VS2010. I'm posting this answer incase others over look the Run as Administrator.
I discovered that I had the same error because of a DataContract that I was using that inherited from Dictionary. The proper setup of the DataContract should be as follows:
[CollectionDataContract(Name = "AdditionalProperties",
ItemName = "Property",
KeyName = "Key",
ValueName = "Value")]
public class AdditionalProperties : Dictionary<string, string>
{
}
This is my experience on this error message,might be useful to others.
My WCF service is working fine on windows 2008 server.I copied the same solution to Dev machine, selected .svc file from solution so that WCF test client can be popped-up.
WCF test client opened with errors cannot obtain metadata,assembly can't be loaded etc.
Key is, first kick up the service (http://localhost:port/Service) then only try WCF test client.
In my case, I had not enabled BindingParams.AllowHttpGet. When that was set to true, it worked...
please check and read all text of error.
in my case another dll has error but show same error in above text of error.
Please check that you can resolve that address and that you have specified the correct virtual directory. Does myserver resolve to an IP with forexample ping myserver? Is myapp the correct virtual directory? You have enabled metadata for your wcf service, but the url is most likely wrong.
I am encountering a strange issue: I call a WCF-Operation from my client. The operation deletes all files in a specified directory and finally deletes their parent directory too.
ACtually, this works. No exception is thrown and the files within the folder and the folder itself are deleted successfully.
But: the wcf context of my client gets invalidated so I need to instantiate the Service Client again. If I do not delete the directory but only the files within everything works fine. Actually I do not have any clue why deleting a directory has an impact on the Client calling the service ??!
Thank You
Sorry for the late reply, but I just wasted an afternoon dealing with the exact same issue. I finally tracked down the issue to the call to Directory.Delete(). It was working fine, no exceptions etc.
In our case we were deleting a subfolder of the folder that hosted the WCF service. From what I understand, this forces the application to recycle, killing your session/service etc
Our service was storing/deleting files, so we moved the file storage location to outside of the applications folder and it now seems to work fine.
More info here:
http://www.geekays.net/post/2008/10/14/ASPNET-webdomain-recycle-on-subfolder-changes.aspx
Are you getting back a SOAP fault from your service call when you delete the directory??
If so, can you enable additional detailed debug information to find out what exactly that fault is on the server??
You do this by adding a service behavior to your config (on the server side):
<behaviors>
<serviceBehavior name="detailedDebugInfo">
<serviceDebug includeExceptionDetailInFaults="True" />
</serviceBehavior>
</behaviors>
and then assigning that service behavior configuration to your service declaration:
<services>
<service name="YourService"
behaviorConfiguration="detailedDebugInfo">
Once you do this, you should be getting back the detailed exception info from a potential server side exception into the SOAP fault you're getting back on the client.
In my website, when a web page is idle for more than 5 minutes, then that page is not working until I refresh. The following error occurs:
Error:
Sys.WebForms.PageRequestManagerServerErrorException:
Validation of viewstate MAC failed. If
this application is hosted by a Web
Farm or cluster, ensure that
configuration specifies
the same validationKey and validation
algorithm. AutoGenerate cannot be used
in a cluster.
I'm already using EnableEventValidation="false" ViewStateEncryptionMode="Never" ValidateRequest="false"
But, nothing is working for me.
Although it's an old question, I will answer anyway because it might help someone else.
So I had this problem in the past few days, and I realized that I started getting this error after I configured my cookies as HttpOnly and Require SSL:
</system.web>
<httpCookies httpOnlyCookies="true" requireSSL="true" />
</system.web>
Turns out that I just forgot to configure Visual Studio to open the SSL URL of my website. So as long as it opened the regular Url, the cookies couldn't be sent, and that what caused the error.
In order to change the default Url, you simply need to figure out what is your SSL url: Click the project on solution explorer and press F4 (not Right Click -> Properties) and over there you'll see SLL URL under the the Development Server section. After that, go to the project properties page (Right Click -> Properties) and in the Web tab, put the SSL Url as the Project Url.
Make sure all the servers on the cluster are using the same encryption key.
This sometimes happens if you are doing a postback from a form which has an action pointing to a different page.