ASP.NET Core Site Deployement - asp.net-core

I am deploying my asp.net core site on Local IIS and binding is
http//localhsot:{portnumber} but the website is not running and giving me error
HTTP Error 404.4 - Not Found
The resource you are looking for does not have a handler associated with it.
Detailed Error Information:
Module IIS Web Core
Notification MapRequestHandler
Handler Not yet determined
Error Code 0x8007007b
Requested URL http://localhost:9001/
Physical Path D:\Deploy\Stagging - Copy
Logon Method Anonymous
Logon User Anonymous
But when my binding is
https//localhsot:{portnumber}
web site runs fine
why this is happening I don't want to run the site on Https

It seems that there is already a binding rule binding your localhost domain name and HTTP protocol.
If you just installed the IIS service and it will create a default site automaticly and bind your 80 port.
Try removing the default website and try again.
And try not set the HTTP host name of your binding and just leave it empty. When you leave the host name empty it will bind all incomming requests from the port.
The difference between IIS http binding and https binding is that HTTP binding is based on the host header in the HTTP request and the https binding is based on SNI. Now your https binding is working fine so it is possible that your HOST name settings caused this issue.

Related

Host Asp.Net Web Api Service on My Computer to access Remotely

I created a default Asp.Net core 3.1 project with Web Api template, It contains weatherforecast controller with one method that is a Get() to retrieve random forecasts, I published this site to a folder on my computer and created a website in IIS manager that points to this directory using default application pool.
I entered my modem by typing 192.168.1.1 in the browser and Picked my ADSL IP address from it, Then I entered this IP address to bindings section in IIS and choose port 80 and http and a name for the site, Finally I enabled directory browsing in IIS and allowed world wide web service in the windows firewall, But when I enter: http://xx.xxx.xxx.xxx/SiteName/WeatherForecast (with xx... the IP I picked from modem) using Get method in the PostMan or in the browser I get Error Message:
403 Forbidden
What is the source of this error and how to resolve this?

Is there a way to force an application to post using https instead of http

I have an application that sends a request to a web service. Unfortunately the application is compiled and the link to the web service is embedded in the application as http. (Yes I know how dumb that is, I didn't write it)
Recently, the 3rd party company is no longer allowing http requests, everything must be https.
The application runs as a webapp on Tomcat. The server is a windows server.
Is there a way to intercept the call to this web service and force it to use https?
As you can't change the application's source code (as it is compiled), and you can't change the web service (as it is 3rd party) either, the only way to solve this problem is making a proxy between the application and web service. To do that, you need to (assume the proxy is running in localhost):
As the web service URL is embedded into the compiled application, in order to let application send HTTP request to our proxy, hosts mapping need to change (e.g. /etc/hosts) to override DNS. For example, if the HTTP request in application is GET http://example.com/api/sample, in /etc/hosts, example.com need to be mapped to 127.0.0.1.
Make a proxy web server in localhost and open the same port as the web service. This proxy is a very simple web server (any backend programming tech can do it), it is only responsible for request-forwarding. In this way, when application send HTTP request to example.com, it sends the request to the proxy server.
After receiving HTTP request from application, the proxy server extract the request URL/header/body and send HTTPS request to example.com's real IP address. Please note: in this HTTPS request, a header host whose value is example.com should be added. 3rd party web service may check this header.
After the real response is returned from example.com, proxy will return it to the application.
Of course, you can also use reverse engineering (Java Decompiler) to get the application's "source code", change the web service URL and then compile again to a webapp. However, as the application may need to update/upgrade and it is may not under your control, this reverse engineering method is not recommended.
You could use a proxy script. Write it in any server-side language you want, for example PHP, set the API URL to this script, the script does the https request for you and pass the results back to your app.
You could also use Apache itself as the proxy and use something like: Apache config: how to proxypass http requests to https

WCF Service hosted in IIS not giving response with HTTPS

I have developed a sample WCF service and hosted in IIS 8.5, Windows Server 2012 R2. Note that this server is added to F5 load balancing setup (I do not know the details of this setup) and I am supposed to invoke this service using the URL https://loadbalanceddomainname/servicename.svc.
In the IIS, I have made the below configurations:
Created a new website
Created a Self Signed certificate with the subject name "loadbalanceddomainname" and imported to the Personal store.
Bind this certificate to this website on port 443, and host header is set to "loadbalanceddomainname".
With this configuration, when I try to browse the URL https://loadbalanceddomainname/servicename.svc, it gives me a 504 Error (as shown in Fiddler -> "
[Fiddler] ReadResponse() failed: The server did not return a complete
response for this request. Server returned 0 bytes.
")
However, in IIS, if I add one more binding to Port 80 with host header "loadbalanceddomainname", I get the response as shown in the screenshot below.
Though I am able to invoke this service using Https (as shown in address bar) in the browser with the port 80 binding added to IIS, I see that it is getting changed to http as shown in the screenshot below where it says "svcutil.exe http://loadbalanceddomainname/servicename.svc". Why is this https getting changed to http? Why is my service giving 504 error when I remove the Binding at Port 80?
Though I get a response in the browser (with port 80 binding in server), when I try to invoke an operation using a test client (by adding a service reference in Visual Studio and creating a proxy), I get error 404 - no such endpoint exists. The WCF trace log shows the below error as well:
Failed to lookup a channel to receive an incoming message. Either the
endpoint or the SOAP action was not found.
I also have noticed that the certificate I have Bind in IIS is not what I see i the browser, in the above screenshot - when I view the certificate details. Is this a different certificate coming from F5 or somewhere in between?
I think you are dealing with this metadata issue. when client tries to access the service over https, it still gets redirected to http because of soap: address location.
https://blogs.msdn.microsoft.com/dsnotes/2014/10/03/ssl-offloading-in-load-balancer-scenario/

CloudHub HTTPS endpoint not working

I have set up an HTTPS endpoint for my mulesoft flow which is working great in local.
https://'localhost':8081/customerquote
Once I deploy it on CloudHub I am not able to contact the url using https, the URL looks like
https://myappname.cloudhub.io/customerquote it is responding only in HTTP reporting an SSL handshake error of course.
Already tried to switch the endpoint port to 443 or 8443 without any results.
Any Idea ?
You need to use properties placeholders when you're deploying to CloudHub:
http://www.mulesoft.org/documentation/display/current/Developing+a+CloudHub+Application
If your application requires an externally accessible HTTP or HTTPS
port to receive messages, trigger events, or expose a web service or
user interface, you must declare the port using the reserved property
${http.port} or ${https.port}. On CloudHub, port ${http.port} or
${https.port} is assigned automatically by the platform services.
Traffic on port 80 to your application domain URL will be routed to
this port.
An HTTPS listener requires a TLS configuration.
Please refer this link
https://developer.mulesoft.com/docs/display/current/Building+an+HTTPS+Service
I did copy the exactly example reported here and it worked
http://www.mulesoft.org/documentation/display/current/Building+an+HTTPS+Service

Silverlight looking at wrong url for clientaccesspolicy file

i have a silverlight app connected to a webservice over https.
The webservice is hosted on mydomain.com (not localhost).
When i run the silverlight, it makes https calls to webservice on mydomain.com, but also tries to access "http://localhost/clientaccesspolicy.xml" and fails obviously. Why is my SL app looking for cal.xml in localhost? why is it not looking for cal.xml in the mydomain.com?
Appreciate your thoughts.
Thanks!
"Before allowing a connection to a network resource, the Silverlight runtime will try to download a security policy file from the domain that hosts the network resource. There are two different methods used to download the security policy that depend on whether the connection request was from a WebClient or HTTP class or whether the connection request was from sockets.
If the connection request was from a WebClient or an HTTP class to a cross-domain site, the Silverlight runtime tries to download the security policy file using the HTTP protocol. The Silverlight runtime first tries to download a Silverlight policy file with a name of "clientaccesspolicy.xml" at the root of the requested target domain using the HTTP protocol.
If the "clientaccesspolicy.xml" is either not found (the web request returns a 404 status code), returned with an unexpected mime-type, is not valid XML, or has an invalid root node, then the Silverlight runtime will issue a request for a for the Flash policy file with a name of "crossdomain.xml" at the root of the requested target domain, using the HTTP protocol."
http://msdn.microsoft.com/en-us/library/cc645032%28VS.95%29.aspx
What does the address look like inside your SL application?
Is the address coming from the ServiceReference.ClientConfig file? If so, make sure that it has a mydomain.com and not a localhost address there.