Get Visual Studios to use subdomain? - asp.net

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.

Related

How to run a web application from the command line in Windows 10?

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

visual studio 2008 localhost URL

everytime I try debug my website I press the F5 key. It will always start with this address
http://localhost:xxxxx/Default.aspx
but the website wont run unless I change the localhost to 127.0.0.1. How do I allow it to run even though it is localhost without having to specify the URL in my project properties?
Add localhost 127.0.0.1 to your hosts file ref http://helpdeskgeek.com/windows-7/windows-7-hosts-file/

Friendly URLs for localhost ASP.NET websites

I Use Visual Studio 2010 with ASP.NET 4.0 and IIS7.
When I open my site, the URL looks like this
http://localhost:6549/Website/help/tab/contact-us
I want a friendly URL:
http://mysite/help/tab/contact-us
or anything that will help me to get rid of the Port 6549 from URL
http://localhost/Website/help/tab/contact-us
I use ASP.NET Development Server which is what Visual Studio use when you run a localhost website
Wait !! Please make distinction between "Properties window" and "Property pages" of the project. I always tried your advices, but using "Property pages", and there is no such property like Use dynamic ports on that page. This property can be found only in the "Properties window"
Assuming it's the ASP.NET development server:
To get rid of the port number you need to do this
- go to properties of the project
- click the web tab
- check the specific port and assign 80
There is also a virtual path setting here which you could set to /
Is your solution configured to use IIS and not the ASP.NET Development Server? There is also a property on the web application where you can specify the port (or allow for a random port to be chosen) - port 80 is the appropriate port - this requires administrator access to the process that is launching the web site.
Edit:
I was thinking you can use your host file to redirect the user, but I checked and you can't redirect to a port.
If you have IIS7 on the machine, just make the location of your web development folder into a virtual directory on IIS.
Then you can access it by http://localhost/website/

Local testing for sub-domains using Url rewriter, Asp.Net 2

I am using UrlRewriting.Net for url rewriting in Asp.Net 2 and IIS 5.1 (offline) and IIS 6 (online)
The application performs the following:
A url of the following nature: http://username.site.com is re-written as
http://site.com/Default.aspx?user=username
This works perfectly online. However, I would like to know how we could test this offline.
I have tried pointing the application to 127.0.0.1 via IIS and then putting username.site.com in the hosts file to point to 127.0.0.1 - but it does not work out.
The website loads up - but the querystring is not generated.
Also tried putting just site.com -> 127.0.0.1 in the hosts file and accessing username.site.com. But in this case, the website does not load (site not found)
Any ideas?
easy way to test this will be to edit your hosts file so that username.site.com points to 127.0.0.1, but you will have to do this for each user you want to test on each PC...
Okay.
I managed to get this working. Its simple if you think about it.
I got myself a DNS server, installed it on my system and configured it to serve me pages from 127.0.0.1 for site.com
If you are wondering, I used a DNS server called SimpleDNS from http://www.simpledns.com/
There is also a free BIND DNS server available from:
http://oldwww.isc.org/sw/bind/view/?release=9.6.1b1&noframes=1
But that was too much for me to configure at this point of time.

Run ASP.NET application as Default Web Site on dev machine

I am trying to run my ASP.NET Web Application Project in my Local IIS Web Server instead of using the Visual Studio Development Server. It seems to only allow me to run my application in a Virtual Directory off of the Default Web Site. However, I would like to run the application in the root of the Default Web Site itself.
I go into the properties of my project, go to the Web tab, click the User Local IIS Web server radio box, and change the Project URL to http://localhost/. However, when I attempt to save, it tells me I need to configure the Virtual Directory, although I am not using a Virtual Directory.
Has anybody made this work before? Thanks!!
It sounds like localhost port 80 is already in use.
IIS creates a default web site that listens on localhost port 80. Have you disabled that before trying to add yours?
Another approach is to have your site listen on a different port, 81 for example.
So far I used a Post-Build event to copy the contents of my project to c:\inetpub\wwwroot\ and I set the Start Action's Start URL to http://localhost/. Not very elegant, but it gets the job done. I would love for somebody to include a more elegant solution.

Resources