Enabling https protocol in .NET MVC 5 application for localhost - asp.net-mvc

I'm trying to enable https protcol for my application that I'm building on a localhost which has a port number like this:
https://localhost:19590/
I have went to the IIS xx express version and enabled https binding and have been able to access localhost (without any port number) via https like this:
https://localhost/
But now I need to enable HTTPS for the project solution I'm working on currently on port 19590, and when I try to access it, it says that the:
This site can’t provide a secure connection
What am I doing wrong here, how can I enable HTTPS for the localhost project on this port number exactly?

In your project properties, in the web section under Servers can you try choosing Local IIS instead of IIS Express and create virtual directory on https://localhost/

Related

How to get URL of OData service from SAP Gateway for connecting it with Web IDE Personal Edition?

I'm trying to connect SAP Web IDE Personal Edition" (local Web IDE) following this tutorial:
https://help.sap.com/viewer/825270ffffe74d9f988a0f0066ad59f0/CF/en-US/2cf47f37e34c428c97a51057733c0394.html
But no connection happens. I guess the problem is in the host URL and the port. How can I get the URL? I tried using S4HANA URL but it didn't work. Also tried Fiori URL didn't work either.
How to get the Gateway URL and port?
If you have an on-premise system, then call /N/IWFND/MAINT_SERVICE, choose your service, click on Gateway Client, set the protocol to HTTPS and you'll see the full URL. If you don't then HTTPS isn't configured for your system --> call SMICM, Goto (from menu), Services and check the Host and Port columns in HTTP row. That's your host and port.

How can I access my localhost on my computer from my Android device?

I have a web application written in ASP.NET MVC 5. I simply can open it from the browser with this localhost:14920 in my computer, but I want to access the same application from my Android device's browser while my laptop and Android device are in the same network. I don't know how to access it from Android.
Note: when I type 127.0.0.1 in the Android browser I can access the IIS server, but when I type 127.0.0.1:14920 it prints Bad Request - Invalid Hostname. How can I fix this issue?
You can configure IISExpress for remote access
http://www.ryadel.com/en/iis-express-allow-external-requests-remote-clients-devices/
or just change the hosting to IIS as the earlier commenter mentioned.
Try with replacing 127.0.0.1 with your IPv4 address.
I have used ngrok in the past, when needing to hit my development machine, or have someone else hit it. It is a very useful tool and very simple to install.
Once you download it, it's just a simple command line:
https://ngrok.com/docs#expose
ngrok http 80
(That is for traffic on port 80) Since your port above looks different it would be:
ngrok http 14920
That will give a URL that you can hit or any machine or device.

Accessing local https site over LAN

I am trying to debug my ASP.Net MVC website when hosted over https. I am hosting this via the IIS instance with Visual Studio. I need to access the website from a mobile device - so I am attempting to access the site via LAN.
I have enabled https via visual studio by going to the project properties and setting SSL Enabled to true. Now, when I debug the site, it starts two local instances; one for http (as usual) and one for https. The internal ports for these are listed when I right click the IIS icon in the task tray.
I do not have an SSL certificate installed. My browser gives me insecure connection warnings, but I just dismiss them - I don't believe these are a concern as I am just testing locally (I could be wrong).
I am using a program called Sharp Proxy to translate these internal ports to external ones, allowing my site to be accessible. 64312 is my internal port for accessing the site over http. Sharp proxy is translating this to 4567. 44300 is my internal port for accessing the site over https. Sharp proxy is translating this to 5678.
Successful permutations:
http://localhost:64312 - SUCCESS
https://localhost:44300 - SUCCESS
http://192.168.0.72:4567 - SUCCESS
Failed permutations:
https://192.168.0.72:5678 - FAIL
Bad Request - Invalid Hostname
The issue is clearly not to do with accessing my machine over LAN as I am able to successfully hit 192.168.0.72 with http.
My question is: What do I need to do to be able to access my https site over LAN via debugging with Visual Studio?
In order to verify the identity of the server you're connecting to, HTTPS needs a hostname to check the certificate against.
Therefore, you cannot connect to an IP address over HTTPS.
You need to use a domain name.

Discover configured HTTPS port in IIS / IIS Express?

Using the [RequireHttps] port in an ASP.NET MVC application causes a redirect to HTTPS on port 443 if the user attempts to access the application over HTTP.
However, in IIS Express, the application will probably not running on port 443. It will, instead, be running on something like port 44301.
I've found various tips for replacing RequireHttpsAttribute with an implementation that takes the alternative port number as a parameter, or reads it from Web.config.
This is clunky, because it requires configuration in more than one place.
Is there any way to do this -- programmatically -- in a generic fashion?
Without trying to pre-empt the answers, some options occur to me:
Is there any way to discover the bindings being used by the instance of IIS or IIS Express that's hosting my app?
Is there any way to read applicationHost.config for the current IIS / IIS Express host?
You can check currently used bindings (of IIS/IIS Express) by running following command
"netsh http show servicestate view=requestq"
You can find applicationhost.config file of IIS Express in %userprofile%\documents\iisexpress\config folder.

Host ASP.NET Web API with hostname and IIS at the same time

I'm trying to host a Web API self host application along with IIS.
My Web API project is running on subdomain1.domain.com. My IIS have a site configurered at subdomain2.domain.com.
As soon as my Web API application is started it takes over everything on port 80 and responds to it - no matter what the hostname is. Is it possible run these to sites side-by-side?
Thanks!
You can set the port in the HttpSelfHostConfiguration constructor. See the code here for an example: http://www.matlus.com/self-host-asp-net-web-api/
*Edit to specify further answer from comment: selfHostconfiguration.HostNameComparisonMode = HostNameComparisonMode.Exact; will allow running the sites on the same port.

Resources