Viewing local ASP.NET application on external machine - asp.net

This question has been asked before (namely, here), and I've found a few blog posts that give some details about how to setup IIS Express (here and here) in order to allow remote connections, but I haven't been able to put all the pieces together for myself. Here's what I've done so far:
Ran this command at the command prompt to make a "URL Reservation":
netsh http add urlacl url=http://my-computer-name-here:80/ user=everyone
Opened up the appropriate port in my firewall:
netsh firewall add portopening TCP 80 IISExpressWeb enable ALL
Added in a new HTTP binding in my IIS Express's ApplicationHost.config for my project:
<binding protocol="http" bindingInformation="*:80:my-computer-name-here" />
After completing these steps, I'm able to run my application locally by visiting http://my-computer-name-here/. However, if I try to visit that address with any other device connected to my local network, I get redirect to my ISP's generic search page.
I also tried navigating to my computer's IP, but I hit a 403 (or a 500 when I navigate to the directory of my project's index.html, found by examining the "Physical Path" debug information provided in the error message). This happens both locally and on external devices.
What else do I need to do in order to connect to my local IIS Express development server from an external device?
In case it's relevant, I'm using the ASP.NET Web API 2 tutorial as a test project for proof of concept. I'm using Visual Studio 2013.

I've found that I am able to connect to the development server externally, but only from another Windows machine. The devices I was using to test for a remote connection (an Android phone, an iPad, and a MacBook Air) are all unable to view the application.
I've asked a new question regarding accessing the application from non-Windows machines here.

Related

Enable HTTP geolocation on local netwrok (not localhost) to allow multiple devices to access web site

I am working on a home project involving Leaflet, Django and GIS. On my main system I am running Linux (Ubuntu 20.04), while I also have an extra system running Win 10 Home. Last but not least I have an Android smartphone attached to the WiFi. All three are part of a LAN managed by my router (typical home setup).
I would like to test how well my Django project is running on multiple devices as well as different web without some advanced browsers.
Using the Live Server extension fro VS Code I can easily deploy a server without having in-dept knowledge about these things. On localhost (dev machine) I am able to load the web site without any issues, however on any other device that is accessing the server that is being run on my dev machine I get an issue regarding HTTP and geolocation.
From what I understand:
In recent years geolocation is allowed only for HTTPS connections or
if running on localhost, which is marked as secure (otherwise it would be too much trouble for the developers).
I am looking for an easy setup (for someone who is not familiar with web servers) to deploy my web site on my LAN and make it available to all connected devices. Is this even possible?
Credit goes to #deceze.
By default the Live Server extension for VS Code has no HTTPS enabled. The protocol is supported but requires extra configuration steps.
As a developer debugging a web site running on localhost is not an issue since such source is automatically accepted as trusted. However if the web site needs to be accessed from another device (e.g. a smartphone or a web browser on a different OS) HTTPS is required.
Inside the VS Code project folder do the following:
Create a self-signed certificate (OpenSSL tutorial on how to do it). If you already have one, skip this step.
Place certificate and corresponding key file at a location, where VS Code has reading access to
Create a .vscode directory if such is not present
Add a settings.json file or edit the one that is already present there with the following entry called liveServer.settings.https:
{
"liveServer.settings.https": {
"enable": true,
"cert": "<ABSOLUTE_PATH_TO_CERTIFICATE_FILE>",
"key": "<ABSOLUTE_PATH_TO_CERTIFICATE_KEY_FILE>",
"passphrase": "<PASSWORD_FOR_CERTIFICATE_KEY>"
}
}
Note that you need the absolute path to the files. Relative doesn't seem to work.
Restart Live Server
In web browser on target system add exception, which will pop up due to the nature of the self-signed certificate (not verified by any certificate authority).

How to publish an ASP.NET web app in local area network in VS2015

I have just made an ASP.NET web application with VS2015 (framework .NET4.6.1). The project is on my computer but I want to make it accessible from other computers in my office (I think we have a local area network). I have IIS installed. How can I do it?
The most solid (but also more complicated way) is to install a server somewhere in the office which can only be accessed from inside. That said, these are the steps I used to do this a while ago, though I can't guarantee they'll work flawlessly (or at all anymore).
Configure IIS Express (VS2015) to accept outside network connections (on the same subnet)
Find out your local IP address, computer user name, and the project port number.
Go to PROJECT_FOLDER.vs\config\ and open applicationhost.config in any plain text file editor (recommended: Atom or VS2015)
In the applicationhost.config, find the sites section in system.applicationHost. In there, you will find a section . Under , add a new binding with . Save, and close.
Open an elevated windows command prompt or Powershell (recommended).
Execute the following commands: "netsh http add urlacl url=http://IP_ADDRESS:SITE_PORT/ user=USERNAME", "netsh advfirewall firewall add rule name="IISExpressWeb" dir=in protocol=tcp localport=SITE_PORT profile=private remoteip=localsubnet action=allow"
Done
When you're finished testing, you should disable the connection settings again.
Remove the bindings in the application.config file you just added.
Run the command "http delete urlacl url=http://IP_ADDRESS:SITE_PORT/"
Delete the firewall rule with "Delete rule name="IISExpressWeb"" in an elevated command prompt.
Use your IP address for deploying in your work network.
Use this link (Step-by-Step with pictures) for publishing in your local network.
(Supports VS2015)
Link 2 : Better Deployment with Support from VS 2010 to VS 2015

VS2012 ASP.Net error message unable to connect to the configured development web server

I bought a new Windows 8 PC last week.
First I installed VS 2010 on it but then that wasn't working properly so I uninstalled VS 2010 and then installed VS 2012 professional edition and SQL Server 2012.
Now I am able to create Windows applications but I am not able to run even a simple ASP.Net website.
When I try to view Default.aspx in browser it throws an error message that
Unable to connect to the configured development web server
so then I went into Add or remove components and installed IIS. but I still get that error message.
Even if I try to save the website at a folder location, the ASP.Net development server is not able to run the web page.
I get the same error message using either IIS or ASP.Net development server.
I am wondering is it Windows 8 security related issue?
How can I make sure my ASP.net Development server was installed correctly and has the appropriate permissions to run?
Does ASP.net work with regular Windows 8? or do I need Windows 8 pro? Microsoft's website doesn't say anything about it so am assuming Windows 8 should work because the Windows forms application works.
Please advise. I just want to be able to run a simple ASP.Net application to verify the installation.
I tried http://forums.asp.net/t/1768992.aspx/1 but that didn't work in this case.
ASP.NET IIS Registration Tool (Aspnet_regiis.exe) would be one of my suggestions along with checking what identity is the Application Pool in IIS using as it may have limited permissions. Last but not least, run Visual Studio as an Administrator so you don't have UAC issues.
All right. I had this problem for a week and I have tried many solutions. Finally, the following procedure will fix the problem.
I have set the Firewall system manually. This means that, at the time of communication by programs Firewall notify me. Incorrectly linked to "devenv.exe" was blocked by the Firewall. Correct mode of communication "devenv.exe" will solve the problem. "devenv.exe" is located in the following path.
"C: \ Program Files (x86) \ Microsoft Visual Studio 12.0 \ Common7 \
IDE \ devenv.exe"
Devenv lets you set various options for the integrated development environment (IDE), and also build, debug, and deploy projects, from the command line.
Enjoy...
I've run into the same general error message that you stated, but the details of my error included the following:
Unable to connect to the configured development Web server.
Failed to register URL “http://10.10.7.209:53553/“ for site
“FooBarSite” application “/“. Error description: The format of the
specified network name is invalid. (0x800704be)
The fix for me was to make changes to the applicationhost.config file located in C:\Users\Jed\Documents\IISExpress\config
Specifically, I had to update the bindingInformation for the site so that the IP Address matched the IP Address of my development computer.
Instructions
Run ipconfig to determine the IP Address of your computer
Open C:\Users\Jed\Documents\IISExpress\config\applicationhost.config (in Notepad)
Scroll down to <sites>, then find the <site> that has the name of your project (in this example it was FooBarSite
Update the bindingInformation so the IP Address matches the IP Address that was determined in ipconfig
Example
<bindings>
<binding protocol="http" bindingInformation="*:53553:localhost" />
<binding protocol="http" bindingInformation="*:53553:10.10.7.209" />
<!-- I had to change the IP Address from 10.10.7.209 to 10.10.7.214 -->
</bindings>

How can I reach my ASP.NET project with my smartphone?

I have an ASP.NET project which developed in visual studio 2010 on my computer.
I can open its pages using address like : localhost:52413/Default.aspx .
I want to reach that page from my smartphone which is connected in same wireless network. How can i do that. First of all i tried 192.168.2.2:52413/default.aspx
What should i do?
If you are using the Visual Studio built-in development server, then you are not going to be able to open the website on another computer (or smartphone). This web server is bound to localhost. But you have three options to test your website on your smartphone:
Use IIS Express
Install IIS Express
Change project settings to use IIS Express instead of the built-in web server
Configure IIS Express to listen to remote requests.
Use IIS
Install IIS
Change project settings to use IIS (instructions for Visual Studio 2008, mostly the same in Visual Studio 2010)
Transfer your files to a web host where you have a domain name and hosting contract
For 1. and 2. you probably also need to configure your local machine's firewall to allow incoming traffic.
This can be done quite easily using Fiddler.
www.fiddler2.com
First download and install Fiddler.
Start the program and select "Tools" -> "Fiddler Options" from the menu.
In the options dialog select the "Connections" tab and check "Allow remote computers to connect".
A 'restart required' dialog may appear.
Now select "Rules" -> "Customize Rules" from the menu.
This opens a text file called "CustomRules". At the end of the "OnBeforeRequest" method (around line 188 or so) add the following:
if (oSession.host.toLowerCase() == "192.168.2.2:8888")
oSession.host = "localhost:2000";
Save the file. Close it. Restart Fiddler.
Start your web application (I usually configure the web site with a static port) like normal and verify that it's viewable on the computer through localhost:2000 (or whatever port number you have decided to use. It must match what you entered in "CustomRules", though).
Now you should be able to browse the web application from any device on your lan provided firewall and such let you by pointing a browser to http://192.168.2.2:8888
Maybe the firewall on your computer is blocking connections to port 52413. Try turning off the Windows Firewall to see if that helps.
local development server can be use only from local machine, publish to your app to or you can install UtilDev Web server (former Cassini)

Viewing ASP.net Development Server from virtual machine

Microsoft recommends testing older versions of IE with the following virtual machines
This is all fine and good, except that the virtual machines can't see the Dev Server from Visual Studio. This makes it very difficult to develop or debug since I have to copy or deploy to IIS for every little change I make. I've tried using ARR, but it seems it can only forward to one specific port at a time, whereas i need to have the port typed in the address bar of the virtual machine to match the port that it is connecting to on the host machine. Is this possible?
You shouldn't need to deploy to IIS to test changes.
We set our IIS up on development machines to point to the web project folder.
Once IIS is setup, you can add an existing website to your solution, select Local IIS and select the Site from the list of sites (rather than browsing the file system and selecting a .csproj file). You'll now have your site in VS that is hosted by IIS, ready to change and debug, and accessible from remote machines.
Generally speaking you cannot access the ASP.NET Development Server on one machine from another.
Here's some additonal notes on what you cannot do with ASP.NET Development Server from MSDN
ASP.NET Development Server is specifically built to serve, or run, ASP.NET Web pages under the local host scenario (browsing from the same computer as the Web server). In other words, the ASP.NET Development Server will serve pages to browser requests on the local computer. It will not serve pages to another computer. Additionally, it will not serve files that are outside of the application scope. The ASP.NET Development Server provides an efficient way to test pages locally before you publish the pages to a production server running IIS.
The ASP.NET Development Server works only with individual pages and does not include the extra facilities of IIS. For example, the ASP.NET Development Server does not support an SMTP mail server. If your Web application involves sending e-mail messages, you must have access to the IIS SMPT virtual server to test e-mail because the ASP.NET Development Server cannot forward e-mail messages or invoke a server that does.
Anyway.....
Googling around I have found an article where somebody had success on accessing a Development Server remotely using a reverse proxy. I have not tried but here's the link
Configuring a Basic Reverse Proxy in Squid on Windows (Website Accelerator)
Also have a look at this StackOverflow question that has answers describing varous methods to achieve your results
Is There a Way to Make Remote Calls to ASP.NET Development Web Server?
You need to type the development server port into the address bar of the client browser, otherwise host the application in IIS and use the default port.
It is overkill to test with this number of configurations in the development environment. It is generally sufficient to test with 2 or 3 configurations while you are writing code (say IE8, FireFox) - just run these from the local machine (no need for a virtual machine). Once you've finished the UI, deploy your application to a test environment running IIS and test it against the larger range of configurations.
If you test each small change against all of these configurations as the change is made, you'll find yourself overwhelmed with testing. Don't forget that as well as the MS recommended test environments, various configurations of other browsers and operating systems (such as FireFox and Opera, Mac OS) are equally important - you may choose to only test a subset of these configurations depending on your resources.
I too found the link Lorenzo mentions in his comment, but had no luck with Squid configuration.
Happily there's a much easier method, as noted here.
Go to CNET and download SPI Port Forwarder
(Note: Click the "Direct Download Link" below the big green "Download Now" button. If you use the Download Now button CNET tries to install adware on your machine before giving you the file. It's very odd.)
In the first column, "Local Port" put the port you want people to connect to your machine on. I wanted people to come in on 80.
Second column, "Remote host", put "localhost" (it'll apparently port-forward to other machines).
Third column, "Remote port", put the port of the local webserver (in my case the ASP.NET Development Server on port 2485).
Click "Activate"
Hope this helps.
I am answering this old question to help peoples who wants to make it work without IIS. Thank you Fiddler !
1. First Step
You have to download Fiddler.
Once Fiddler is downloaded and installed, open it.
Go in Tools-> Fiddler Option-> Connection tab-> And check "Allow remote computers to connect" :
Restart Fiddler.
2. Second Step
After this, in the VM, open internet explorer-> Internet Options-> Connection Tab-> Lan Settings-> Check "Use a proxy server for your LAN" :
The adress is the IP adress of your DEV machine.
And put the port 8888
Now, you can access the ASP.NET Web Server from your VM !
To access it -> http://localhost.:54814
Don't forget the additional point after "localhost" !
The port, "54814" in my case, is the ASP.NET Web Server port.

Resources