How to run a web application from the command line in Windows 10? - asp.net

I've built a web application (i.e., it's got .aspx pages and .dlls, but no .exe) in VS2017. I need to be able to invoke this application on my local machine from the command line. Does anyone know how to do this?
I tried
explorer http://localhost:59135/OAuth2Manager.aspx
But I get an error page saying "This site can't be reached". (If I run the solution from Visual Studio, it comes up with no problem.)

Create site in IIS. Right click it then edit bindings. Use this settings for local use:
type: "http"
Host Name: "YourName.local"
Port: 80
IP Address: *
Also you will need to modify your hosts file to point to your site to the correct address.
Go to
Windows/system32/drivers/etc/hosts
and add: "YourIP" "YourName.local" or use local host IP for example:
127.0.0.1 mysite.local

Related

How to install dotnet core 6 webapp on IIS server window 11

According to the web, I should be able to install on Windows 11 (as well as server, et al).
I have an application (Hunter.API), that I can run in debug perfectly - both with Swagger as well as simply entering a Url in the browser (does an http get to a controller that returns some data from SQL Server).
Next: I published using: dotnet publish -r win-x64 - -self-contained (that's a double dash without the space between).
I created a site on IIS:
[IIS Mgr][1]
[1]: https://i.stack.imgur.com/K47fK.png
Bindings: http localhost 80 * (wasn't sure what to put for host name; btw, I stopped the default web site that was using port 80.
Basic Settings: Sitename: HunterAPI App Pool: HunterAPI
Path: down to \Hunter\Hunter.API\Bin\Release\net6.0 ??
Then I select from the right panel: Browse localhost on *.80 http and get the same that the Default Site would have produced.
Tried going to c:\Windows\System32\drivers\etc\ and opened the hosts file.
Added a line 127.0.0.1 HunterAPI.com (I have no clue; some site said something like that)
Restarted and no change.
Then I changed the binding port number to 8081, restarted.
got 403.14 error which suggested: A default document is not configured for the requested URL, and directory browsing is not enabled on the server.
I'm lost and out of options.
Any suggestions?
Thanks in advance.

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.

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.

Get Visual Studios to use subdomain?

While writing an asp.net project i may have this url for testing/debugging
http://localhost:1234/
I have code that takes in account of subdomains. Can i make visual studios call the same code with
http://anysub.localhost:1234/
You can update your hosts file and put in any subdomin for the localhost:
127.0.0.1 example.com
127.0.0.1 sub.example.com
You can then point your browser to either domain. So long as the debugger is attached to IIS/Dev browser, you will be able debug your server side code.

Simulate domains locally in ASP.NET /IIS7

I would like to simulate that my ASP.NET application is hist by say simdomain.com.
How can i do that easily?
Ideally I would like some kind of filter, so requests to certain domains are routed to localhost, and it should be easy to turn it on and off.
Edit the hosts file.
Run notepad c:\windows\system32\drivers\etc\hosts
Add the following line:
127.0.0.1 simdomain.com
Open IIS admin and add a "simdomain.com" website. So it knows the domain.
Try editing you local hosts file. The default location is %SystemRoot%\system32\drivers\etc\hosts in most Windows systems.
Then you simply add the line
127.0.0.1 simdomain.com
That should do it.
EDIT: Ah, and as Chakrit said: Open IIS admin and add a "simdomain.com" website. So it knows the domain.
This depends a bit on IIS version, but if I remember correctrly for IIS7 do as follows:
Run 'inetmgr', or access the IIS setings via the Control Panel.
In the menu on the left open 'Sites', and right-click on the site you want to access. Choose 'Edit bindings..'
Click add. Type: Http, IP Address: All Unassigned, Port: 80, Host name: simdomain.com then click OK.
Might as well make my answer correct, even if the post is a tad redundant. ;)
Maybe have a read of this SO discussion; "ASP.NET Development server or localhost IIS"

Resources