Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Project URL Visual Studio

I would like to be able to debug my ASP.NET MVC application on a domain other than localhost as well as any subdomains, in other words:

http://domain.dev http://*.domain.dev

I have tried the following:

  1. Modify the Hosts file
  2. Add a Host record for *.domain.dev that returns 127.0.0.1
  3. Change the 'Project Url' in the project properties.

However, nothing is working. When I start to debug I get a page that either says "Service Unavailable" or "Invalid URL".

What am I missing?

p.s. I am using Visual Studio 2013

like image 636
William Avatar asked Jan 07 '14 18:01

William


People also ask

Where is the project URL in Visual Studio?

Switch HTTP to HTTPS for an existing app in Visual Studio For the web project configured running on HTTP, right click the project and click properties: The Project Properties Window is open, click Web Tab, we can see that the Project Url is HTTP protocol.

How do I change the local host in Visual Studio?

Click the Web tab. In the Servers section, under dropdown selection for IIS Express, change the port number in the Project URL box. To the right of the Project URL box, click Create Virtual Directory, and then click OK.


2 Answers

For Visual Studio 2015 the steps in the above answers apply but the applicationhost.config file is in a new location. in your "solution" folder follow the path

\.vs\config

Within that folder you will see your applicationhost.config file

Alternatively you could just search your solution folder for the .config file and find it that way.

I personally used the following configuration:

enter image description here

With the following in my hosts file:

127.0.0.1       jam.net
127.0.0.1       www.jam.net

And the following in my applicationhost.config file:

<site name="JBN.Site" id="2">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="C:\Dev\Jam\shoppingcart\src\Web\JBN.Site" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:49707:" />
            <binding protocol="http" bindingInformation="*:49707:localhost" /> 
    </bindings>
</site>

Remember to run your instance of visual studio 2015 as an administrator! If you don't want to do this every time I recomend this:

How to Run Visual Studio as Administrator by default

I hope this helps somebody, I had issues when trying to upgrade to visual studio 2015 and realized that none of my configurations were being carried over.

like image 109
njfife Avatar answered Nov 01 '22 20:11

njfife


You need to actually create a new record for each subdomain in the hosts file. You can't use wildcards.

127.0.0.1 domain.dev
127.0.0.1 foo.domain.dev
127.0.0.1 bar.domain.dev

Although it seems that it can be done with some extra work, see this question for more details.

You also need to include the port number when accessing the URL. The browser would point to http://foo.domain.dev:0000, using the port number assigned in VS, of course.

If you are using the Visual Studio Development Server, that's all there is to it. If using IIS Express, it takes a bit more work.

VS project properties

Then you need to make sure you have a record in the IIS applicationhost.config file :

<site name="YourApplication" id="25">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="C:\Path\To\Your\App" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:2750:foo.domain.dev" />
    </bindings>
</site>

Update

<site name="DomainProject" id="18">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="C:\Users\William\Source" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:32939:domain.dev" />
        <binding protocol="http" bindingInformation="*:32939:domain2.dev" />
    </bindings>
</site>
like image 45
dom Avatar answered Nov 01 '22 22:11

dom