How can I change an html output of wcf service with my own content?
You need to turn off the publication of the service's metadata.
You can disable it in the Web.config:
<serviceMetadata httpGetEnabled="false" />
You can find more information on MSDN here:
http://msdn.microsoft.com/en-us/library/system.servicemodel.description.servicemetadatabehavior.httpgetenabled.aspx
http://msdn.microsoft.com/en-us/library/ms731317.aspx
Of course this will still generate a default landing page if a user manually enters the service's URL in the address bar (e.g.: http://www.examle.com/service.svc). However now it will mention that the metadata is currently disabled.
If you want to customize that page I'd suggest you check out the following thread, it contains a complete code sample on how to set it up:
http://social.msdn.microsoft.com/forums/en-US/wcf/thread/5778651a-b212-438a-b3e8-f7029775d52a/
How to change default WCF page returned in browser?
No, and no.
The service page that WCF produces is hard-wired, and I haven't ever heard of any trick or technique to change it. And no, you cannot get back the old ASMX service page, either.
There's a couple of things you can do:
based on your WSDL that completely describes your service, you could create an HTML help or man page (or pages) and have those displayed under a static URL (e.g.
http://myserver/myservice/helppage.html
)you could create a totally separate page to describe your service, like the one you linked to, and make that available
Mind you: WCF services are by default SOAP based service calls - you cannot just call those from a web browser.
Return html format on wcf service instead of json or xml
Returning a stream allows you to return a raw string:
[System.ServiceModel.Web.WebGet( UriTemplate = "c" , BodyStyle = WebMessageBodyStyle.Bare )]
[OperationContract]
public System.IO.Stream Connect()
{
string result = "<a href='someLingk' >Some link</a>";
byte[] resultBytes = Encoding.UTF8.GetBytes(result);
WebOperationContext.Current.OutgoingResponse.ContentType = "text/html";
return new MemoryStream(resultBytes);
}
WCF Service Client: The content type text/html; charset=utf-8 of the response message does not match the content type of the binding
Try browsing to http://localhost/ScraperService.svc in the web browser on the server hosting the service, using the same Windows credentials that the client normally runs under.
I imagine that IIS is displaying an html error message of some description instead of returning xml as expected.
This also can occur when you have an http proxy server that performs internet filtering. My experience with ContentKeeper is that it intercepts any http/https traffic and blocks it as "Unmanaged Content" - all we get back is an html error message. To avoid this, you can add proxy server exception rules to Internet Explorer so that the proxy doesn't intercept traffic to your site:
Control Panel > Internet Options > Connections > LAN Settings > Advanced > Proxy Settings
Related Topics
Is There a Web Service for Converting HTML to Pdf
How Put Percentage Width into HTML Canvas (No CSS)
How to Force Horizontal Scrolling in an HTML List Using CSS
Convert HTML Character Entity Encoding in R
How to Semantically Tag Poem Text
How to Center Two Divs Floating Next to One Another
Svg Fill Animation for The Given Path
How to Conditionally Display Element Attributes Using Angular2
Are Nested Span Tags Ok in Xhtml
Why Td Width Is Not Working or Not Followed
Controlling Spacing Between Table Cells
How to Style Unordered Lists in CSS as Comma Separated Text
Force Ie Contenteditable Element to Create Line Breaks on Enter Key, Without Breaking Undo