ASP .NET served on local ip not localhost - asp.net

On a ASP .NET project, as I needed to see my local work on my phones, I wanted to switch from "localhost" to local ip.
I changed applicationhost.config :
after the existing localhost nodes, adding :
<binding protocol="http" bindingInformation="*:64645:192.168.XXXX" />
<binding protocol="https" bindingInformation="*:44314:192.168.XXXX" />
But nothing works, when building and running the project applicationhost.config is overwritten, those two lines disappear and back to initial state, indeed runs localhost:44314
I use JetBrain IDE
If you have any clue, merci !!!

From your description, I assume that you have hosted your Asp.Net site on the IIS web server and you would like to access the site in your local network using a mobile device. (Please correct me if I misunderstood something).
In the case mentioned above, you could refer to the steps below.
Open the IIS, and select your site. Go to the bindings.
Add new HTTP binding. Keep the Hostname empty. Select the desired port. Keep the IP address All unassigned.
Go to Firewall settings. Add a new inbound rule. Add the port that you are using for your site. Complete the steps by clicking the Next button.
Restart your site in the IIS.
Now you could access the site using [IP Address]:[Port Number] within your network using any device.
By referring to the same steps you could configure the HTTPS binding.

Related

Host ASP.Net MVC Site

I've created a site using ASP.Net MVC that is meant to be stored on a local machine at my place of work. The intention is to have the site stored on this machine, but then accessible by all the other machines within this building.
I've followed Microsoft's tutorial as well as Code Project's tutorial, but I am not having very much luck. The binding is just the localhost, port 80, with * for the IP address. The URL is localhost/GrantTracker.
I've opened the ports within the firewall, checked the permissions on the directory (which is just within wwwroot), tried having the site take the place of the default IIS site (as Microsoft tutorial has you do) and tried having the site stand on its own with its own port (per Code Projects tutorial).
On the host machine I am receiving the standard "This site can't be reached, localhost refused to connect" which feels like either a port or permissions problem. I must be missing a step, but I can't seem to find what it would be. I am new to hosting sites through IIS so forgive me if I am just missing something basic.
I find it a bit strange too because my project uses Windows Authentication and when the site is first visited it performs that initial check with the user, authenticates, but then throws me the error.
Anyone have any ideas? Thanks in advance.
start simple,
create a simple html page, create an IIS application for it, on port 80.
Check and make sure you can see that page from another computer using the internal IP address of the the host machine so something like:
http:\\192.168.0.3\hostapp\test.html .
You can see the proper URL by running it from IIS, this will give you the entire URL you need, with localhost then just replace localhost with the IP address of the host machine to see it on other machines.
Do this in the original IIS folder so you don't encounter any folder permission issues. If you choose another folder you'll have to give access to the Network Service user ( i think, can't remember now, but there is a specific user that needs access to the folder where the website is deployed )
if you can see the page then deploy a proper website and do the same thing. Make sure the app pool is created correctly and it's up and running, then access it again on other computers and it should work.
Port 80 should be open by default so that should not be an issue.

How to point the website to a particular Folder in IIS

I am a beginner in web development. I am not sure how to tell the website to point to a particular folder in IIS. I have ASP.Net MVC - 5 Web Application.
Step 1. Bought a domain/url.
Step 2. Bought a server with IP Address (Windows Server).
Step 3. Pointed the url to the Server's IP Address..
Step 4. Have locally published my webapp code from visual studio. And now I need to paste this code on the server.
Question 1. Now where do I need to put the code in server so that the IIS will host it and anyone visiting that website will hit that folder which has all my website code. I am a beginner please guide me.
Question 2. In future I will put another web site code too on that same server, let's say the URL for new web app is xyz.com. How to tell xyz.com to go to the other folder dedicated for it, and not the older one. Basically, How multiple web site hosting will work?
PS: using remote desktop client. I am able to log in to my windows server.
In IIS, by default one site is created which points to "%SystemDrive%\inetpub\wwwroot" and it has a default HTTP binding where it listens to all incoming requests on PORT 80.
Now in your scenario, you have several options. You can either create a new site and point it to the folder where your published code resides or you can edit the existing site configuration to point to the folder where your app resides. Below instruction is to edit the exiting site configuration:
Launch IIS Manager
Right click the Default Web Site and navigate to Manage Website > Advanced Settings
Under Default settings, update the physical path to point to the folder where the app resides.
NOTE: you will have to give permissions to IIS_IUSRS account on
the folder or run the application pool under the context of a user
which has necessary privileges to read from the directory.
FYI, all the IIS configuration resides in applicationhost.config file which resides in C:\Windows\System32\inetsrv folder.
Inside this file, the site configuration is present under the <sites> xml tag.
Here is an exmaple:
<sites>
<site name="Default Web Site" id="1">
<application path="/">
<virtualDirectory path="/" physicalPath="%SystemDrive%\inetpub\wwwroot" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:" />
</bindings>
</site>
</sites>
I wouldn't recommend editing the file directly as it can be prone to human errors. I would recommend to use appcmd commandline utility instead.
You can leave the binding as it is. As per the above binding, all the requests that hits port 80 on the server will be handled by the web app. If you intend to add HTTPS support, then you will have to purchase a SSL certificate and then add a SSL Binding for your site.
The website usually goes in the C:\inetpub\wwwroot folder. That is the default IIS root directory. You can change this if you please in the IIS settings mentioned below.
For the second website, you can add another folder anywhere on the server, technically. In IIS: Right-click Sites -> Add Web Site and then set the physical path and other details to your new site's file directory.
Edit: I missed the DNS part. You just have to point the DNS name through your hosting company to the IP and port of your website. For the second site, just put it through a different port and point to the same IP and that port. There's other ways to do it, however: Multiple domains on same webserver

What is the worker process account in machine.config if <processmodel autoConfig="true">?

I'm trying to run a website on localhost using IIS in Windows 10.
I'd like to be able to access the website through another pc in the lan using a local ip address and port. I just started debugging the application in visual studio 2015, I could run
<binding protocol="http" bindingInformation="*:51258:localhost" />
but using
<binding protocol="http" bindingInformation="*:51258:192.168.1.213" />
causes an "Access Denied" popup in visual studio
I've followed the steps in
https://support.microsoft.com/en-sg/kb/894433
but was confused with step 7 i.e.
7. Add the worker process account that is configured in the processModel element in the Machine.config file
I was able to locate the machine.config file but the process model is set to autoconfig=true i.e.
Do I have to setup a custom account or is there a default worker process account that I'm not seeing?
This is so that I can do the following steps to solve the access denied problem...
5. In the Policy pane, right-click Impersonate a client after authentication, and then click Properties.
6. Click Add User or Group.
7. Add the worker process account that is configured in the processModel element in the Machine.config file.
Please note that I have already added the IUSR with permissions to the directories I'm running the website from.
ok after some more digging I finally made it work. I didn't have to add any worker account in the process model block of the applicationhost.config
I just had to install HTTP Activation from the advanced service as described in one of the answers in
what to do when accessing http://192.168.1.213:51258/Default.aspx doesnt work
I then followed with
netsh http add urlacl url=http://192.168.1.213:51258/ user=everyone
But that didn't solve it so I followed the change of configuration in visual studio web server to use custom server to finally fix this, found in the link below
how to setup custom web server in visual studio

"Unable to launch the IIS Express Web server" error

I receive this error when trying to launch IIS Express from Visual Studio with a project that's configured to listen to an address other than localhost. Visual Studio freezes for about 30 seconds before giving the error "Unable to launch the IIS Express Web server".
I've tried all the solutions posted to similar questions and I think I've done everything correctly. Here are the steps that I have taken:
Add the following reservation to HTTP.SYS:
netsh http add urlacl url=http://+:36899/ user=Everyone
Run Visual Studio 2012 as an administrator (technically I don't think I should even have to since I set up HTTP.SYS manually).
Disable Windows Firewall.
Delete my IISExpress folder in my My Documents folder to ensure the default settings.
Allow Visual Studio to create the entry in applicationhost.config for my web project. Then manually edit the config file to change localhost to 192.168.0.100 which is my local IP. Then go back into the project properties in Visual Studio and change localhost to the IP and save the project so that my project is now set to http://192.168.0.100:36899.
I also tried changing the port and repeating the above steps just incase the port was in use for some reason.
I want to make my IIS Express developer instance accessible from my IP on the Internet for remote testing.
If using VS2015, close the solution, delete the following file, then re-open the solution.
<<path_to_solution_folder>>\.vs\config\applicationhost.config
note the .vs folder may be hidden
The one thing that fixed this for me was using the following line in the <bindings> section for my site in the applicationhost.config file:
<bindings>
<binding protocol="http" bindingInformation="*:8099:" />
</bindings>
The key was to simply remove localhost. Don't replace it with an asterisk, don't replace it with an IP or a computer name. Just leave it blank after the colon.
After doing this, I don't need to run Visual Studio as administrator, and I can freely change the Project Url in the project properties to the local IP or computer name. I then set up port forwarding and it was accessible to the Internet.
EDIT:
I've discovered one more quirk that is important to getting IIS Express to properly serve external requests.
If you are running Visual Studio/IIS Express as an administrator, you must not add a reservation to HTTP.SYS using the "netsh http add urlacl ..." command. Doing so will cause an HTTP 503 Service Unavailable error. Delete any reservations you've made in the URLACL to fix this.
If you are not running Visual Studio/IIS Express as an administrator, you must add a reservation to the URLACL.
I had exactly the same issue. Tried everything but finally one trick worked.
Delete folder IISExpress from "My Documents"
Load your project again, it will create IISExpress folder again with updated configuration
Check IISExpress folder has sufficient permissions to read-write the configuration file
Load project again and Run IISExpress. It should work.
Close your project.
Go to folder settings and select show hidden folders option.
Open the folder where your application is. You will see a .vs folder.
Open the .vs folder, you will see a config folder in it. Delete its content.
Run Visual Studio in admin mode. Open your solution from the File menu.
Clean your solution.
Build it.
Run it and voila!
I do not recommend deleting IIS Express folder or messing with the config file in it.
I was changing this entry (for which my web server was not running and showing me access denied error for a particular port)
<bindings>
<binding protocol="http" bindingInformation="*:61235:localhost" />
</bindings>
in the "applicationhost.config" in "Documents\IISExpress\config" for a particular webapplication it was overwritten by Visual Studio 2012 again to default port whenever I was starting my webapplication.
But I resolved the problem by doing nothing in the applicationhost.config. I just changed the "project properties" > "web" > "project url" setting from http://localhost:62135/ to http://localhost:47279/(depends on your computer) and it worked for me.
Try this:
Open Properties of your solution
Go to web
under LOCAL IIS, Change written port number to any other port number and create a
new virtual directory.
Simply start your Visual Studio as Run as Administrator
Thanks,
I had the same issue, but with a different cause that may help others.
Use a commandprompt in admin mode for this:
- TYPE: netsh http show iplisten
If there are any IP entries:
- TYPE: netsh http delete iplisten
Repeat until the list is empty. Check if IIS Express starts now.
Hope this helps,
Niels
Deleting the unnecessary site entries from applicationhost.config file solved the issue for me.
For me it was the applicationhost.config file in .vs folder in my project solution folder(.vs folder is hidden by default).So,I closed the project and delete the .vs folder (vs will recreate it again when you open the project) then reopen the project and run it.
In my case i tried following things to fix this problem.
Delete the iisexpress folder from "MyDocuments"
Go to Solution Explorer --> Right click on the Project --> Go to Properties --> Go to Web tab --> See the Servers --> click on radio button "USe Visual Studio Developtment Server"
I hope this will help you.
I fixed it with the following steps:
Close Visual Studio
Run netsh http show urlacl and see if your application http address/port is listed.
Run netsh http delete urlacl url=[ADDRESS] replacing [ADDRESS] with the Reserved URL shown by the previous command. For example http://+:17560/
Run VS again (as Admin) then go to web project's Properties -> Web then click on Create Virtual Directory button.
Now you should be able to run the web project.
In Debug > Website Properties.
change port number in Project Url to any nearest value and save
I spent 1 hour trying every recipe mentioned above. Then out of no where I restarted my computer, and tried again. And everything is fine now.
So please try restarting your computer before trying all the above mentioned solutions. It might help
I had the same problem with Visual Studio 2012. I managed to resolve it by removing from C:\Program Files (x86)\IIS Express\AppServer\applicationhost.config path unneccessary site entries. Alongwith running my VS2012 as an Administrator. Hope this helps
At the start, Try to disable your firewall. It helped me. The Eset Smart Security 5 blocked it.
I had this problem some days ago and all of above items could not help me.
I have ESET Smart Security 5.0 on my SONY VAIO laptop which works in interactive mode!
Finally I found the problem, ESET was blocking VS2012!
In the past, ESET had asked me to allow the VS2012 to communicate with Microsoft, I had chosen "Deny Access" and ESET had mad a rule for denying
VS2012. I omitted this rule from "ESET rules zone" and my issue was solved!
Delete IISExpress folder in my My Documents folder to ensure the default settings or restore the same to previous version when it was working fine.
Remove the default website from the <sites> </sites>
<site name="WebSite1" id="1" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
</application>
<bindings>
<binding protocol="http" bindingInformation=":8080:localhost" />
</bindings>
</site>
and your own <site> </site>
and run "C:\Program Files\IIS Express\iisexpress.exe"
http://www.iis.net/learn/extensions/using-iis-express/running-iis-express-from-the-command-line
In VS 2013 I saw this error after setting up Google Docs synchronization on My Documents. Updated permissions to not be read-only and problem solved.
open command prompt as administrator
then execute this command :
netsh http show urlacl
you will see the url you have added before
now you should execute this command :
netsh http delete urlacl url=http://+:36899/ user=Everyone
please check the url from list when using :
(netsh http show urlacl)
I face this issue, All I did was go to the web project Properties -> Web -> In the ProjectUrl I clicked on the "Create Virtual Directory" and my issue was fixed.
I had the same issue with my computer having loads of windows updates.
Spent few hours trying to resolve the issue using above answers with no luck.
In past we have different issues due to anti-virus which caused the application to be blocked by it, so thought to try by disabling it.
So after trying all the solution, I just uninstall "One Drive" from my PC & the problem is resolved.
N.B:
I was trying to run .net core web application.
Visual Studio 2017 version 15.9.5
Windows 10 Pro, 64 bit
Click the Solution and press F4. Then match the port from Right-click on solution and select Properties to the web tab port.
The port no will be the same of both case F4 and Properties.
Tried deleting IISExpress folder, changed port , restart VS and PC but it didn't work.
However it worked after killing iisexpress.exe service in services.
change the parameter in the registry
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP
parameter Start from 4 to 3 and reboot

Set up ASP.NET web app on server and run on other computer in the network

I googled this a bit, but could't find anything useful.
I need to set up my ASP.NET web app on my server, but run it from another computer in the network.
How can I do this?
The idea is to have the files on the server and run the app by typing the ip adress of the server in the browser adress bar to run it.
eg. 158.1.6.102/myApp.aspx
Any help is appriciated!
Thanks!
Andrej
Steps:
a. Set up the site in IIS on your server. Make a note of the Host Name under the basic binding properties e.g. MyApp.local
b. Set this in your hosts file (%WINDIR%/system32/drivers/etc/hosts) on your workstation machine.
...
MyApp.local 192.168.1.100 <use the IP Address of your Server />
...
c. In the Properties sheet for your Web Application in Visual Studio (right-click the web project in Solution Explorer and get 'Properties') go to the 'Web' section and put a dot in the radiobutton that says 'Use Custom Web Server' and set the 'Server Url' field to http://MyApp.local (or whatever you put for step 1).
d. Build and Go/Debug!
hth
you need to publish it on webserver (IIS) and then you can access it from another machine.
(assume that ip address of webserver is 192.168.0.1)
http://192.168.0.1/webapplication
the most important is the windows firewall of webserver should allow access to another machine.

Resources