Host Asp.Net Web Api Service on My Computer to access Remotely - asp.net-core

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?

Related

How can I access web api though my Wi-Fi?

I am building a .net 7.0 core minimal web api in VS2022 and would like to be able to access the swagger index.html page outside localhost, for example from my iPhone over my home network.
I have tried adding my home ip address to the urls in launch settings.json to no avail and worked through various links such as configuring kestrel endpoints, Rick Strahl’s post on exterior kestrel endpoints, but still not able to connect outside local host!
I have tried running the application in both iis express and https debug settings.
You can use services like ngrock.
Check out this answer.

ASP.NET Core Site Deployement

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.

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/

Problem with call WCF Service From local host to Server IIS

Hi All
I Have a service project that hosted it in local IIS and within this project i have a refrence to another service in an IIS on another server in this Domain but when i want calling this service I get an exception:
{System.ServiceModel.Security.SecurityNegotiationException: The caller was not authenticated by the service.
How I Can Solve It?
thanks
Check with hosing by console.
Check Domain access for user or port restriction.
when you host then try checking whether it is generating wsdl by just typing http://.. in IE

Asmx webservice IP Address change issue due to hosting in internet

I have a asmx webservice which is accessed from office intranet. I could consume through my flex app with the local IP Address of the hosted system. When that particular system was exposed to the internet, the external IP got changed. Now If I use the same flex app using exposed URL, the wsdl is not getting loaded. Reason being the WSDL is accessed using the outbound IP and the request was trying to route to the intranet IP. The Intranet IP being not exposed, gives a webservice load error.
This is why you should always use a named route and not an IP address.
you should use something like
webservices.your_domain.com
When you are in development, you edit you hosts file so that this address will be routed to the local IP, when you are in production the DNS will route to the real URL.
Never, Never use an IP, this is not best case, and you can have many errors with it.