Visual Studio 2017 - Giving remote users access to website in IIS Express - asp.net-mvc

Been looking through and trying all guides i found on this topic but no luck. I am running and MVC project with HTTPS and want to access the debug site with some remote mobile devices to test out the website. I followed a guide that almost work and i think I am pretty close to getting it to work. Here are the steps I have done:
Turn off Firewall
Open projectfolder of website go to \vs\config\ and open applicationhost.config
Find your site and line that contains your mapped port like this:
-edit it to get this result:
Tried to run Visual Studio as Admin at this point, Got regular error 400: Bad Request - Invalid Hostname when trying to access site from other computer
Opened CMD as Admin and ran the following command:
netsh http add urlacl url=http://*:44363/ user=everyone
- URL reservation successfully added
-Tried to start Visual studio as admin and non admin. Gets the following error message
"Unable to launch the IIS Express Web Server.
Failed to reister URL "https://localhost:44363" for site "x" Application. Error description: Cannot create file when that file already exists"
-I then have to run cmd again and remove the url with the command:
netsh http delete urlacl url=http://*:44363/
How do i get this to work with Visual Studio 2017 ? I cant be many steps from getting it to work. I have read many guides but none of them works

Amazing how such a simple common need can be so painful to fulfill out of the box in 2017!
Anyway https://github.com/icflorescu/iisexpress-proxy worked nicely for me.
Install it with node:
npm install -g iisexpress-proxy
Then its just something like:
iisexpress-proxy 51123 to 3000
Under 2 mins to get running.

Let me share my experience with Visual Studio and IIS Express that should help you. I am not using HTTPS and my project type is Web site with WCF but you should be able to accomplish your goal.
Here are prerequisites:
IIS Express installed
Visual Studio installed
Added url reservation for public port (netsh http add url=http://*:50001/ User=Everyone) from elevated command prompt.
Added firewall inbound rule for 50001 TCP port (Control Panel-->Windows Firewall-->Advances Settings-->Inbound Rules-->New Rule...)
Now let us setup a project in VS. I am using one of predefined templates with C#. Compile it and try to run it from VS. At that moment VS is starting developer instance of IISExpress that helps your site to run.
You should be able to see IIS Express icon in Notification area. With right click you will see that your site is running and a port (we will call it VSPORT) that is assigned by VS. This port must be different than reserved port (50001).
If you managed to accomplish this without problems then you have almost everything ready for running your site without VS.
Go to your project folder
Go to .vs folder
Go to config folder
Open applicationhost.config
Locate sites/your_site section
Copy everything between your_site and /your_site
Now we need to add this info in "global" IIS Express config.
Go to IIS Express folder (something like c:\Users\USERNAME\Documents\IISExpress)
Go to config folder
Open applicationhost.config
Locate sites section.
Paste information about your site.
Change binding from
binding protocol="http" bindingInformation="*:VSPORT:localhost"
to
binding protocol="http" bindingInformation=":50001:"
Save changes
With this change you may start IISExpress.exe directly and you can continue to use VS to work on you project at the same time.
If you want to access it from other computers do it as http://YOURIP:50001/.
Do have in mind that you need to ensure that your javascript code is NOT using address and port number directly.

You can solve the problem by downloading the 'conveyor' library from extensions and update in Visual Studio.
You can access it from other devices.
Open Visual Studio
Tools > Extensions and Updates
Online > Visual Studio Marketplace
Search 'Conveyor'
Download and install this extension
When you launch the API, you can access it from other devices. This plugin creates a link from your own ip address.
Example:
https://youripadress:5000/api/values

Related

My browser cannot find localhost when running VS2017 project and says 'Cannot reach this page'

I've been making some changes to my MVC project which earlier today was running fine. However, I installed some new software including PostGreSql and npgsql for Visual Studio and now when I run my project it seems IIS can no longer find localhost. The actual message is 'Cannot reach this page. Make sure the web address http://localhost:4068 is correct'.
I've checked that my IIS is running and I've tried deleting my IISExpress folder, deleting the config file in .vs/config but so far nothing seems to work and I don't even know what it was that caused it. If anyone has had this issue, please let me know how you resolved it.
The most likely scenario is that your project's properties have changed.
Have you checked the web settings? (right click on project -> properties)
You need to put an entry in your c:\Windows\System32\Drivers\etc\hosts File like
127.0.0.1 localhost
Or simply try http://127.0.0.1:4068 as url
Editing the file needs administrative rights so you might run your editor as administrator.

How do I set the URL from localhost to localhost/applicationOne in Visual Studio?

I have a web application that at the moment is running on http://localhost if I use Visual Studio to run the solution.
I would like to change the settings so that VS starts running it on http://localhost/applicationOne as the starting point.
I want to replicate an issue that seems to be happening only if the web application is deployed to a directory that is not of the root directory in an IIS server.
How do I go about doing this?
You can edit the properties of the project, and set the Project Url.
If using Local IIS
Note: this will require Visual Studio to be run as an Administrator. Behind the scenes, a virtual directory will be created in IIS, and launching the project (e.g. via debugging with F5) will launch the browser, using the Url specified here.
If using IIS Express
Effectively the same settings apply with IIS Express. Note the port number in the Url.

Deploying MVC file system publish on IIS7

I have created an MVC application in Visual Studio 2013 and I now wish to deploy this on the IIS of the server so that all employees from within the company will be able to access it via their windows login credentials.
When I run this in localhost via Visual Studio debug it works as expected but I have been trying unsuccessfully to deploy this to a network server and I am unsure of the process and would be grateful for some clarification.
I chose a file system publish from the publish options but I am unsure as to how to get this accessible as an application. I have tried adding the files via the new website wizard and tried the url of 'holidays/' which I had entered but without success. I then tried to add the same virtual directory location as an application from within this website but again this was unsuccessful.
I use Web Deploy with VS. Your target server needs to also have Web Deploy:
Installing and Configuring Web Deploy on IIS 7
Once your target server is ready, you can deploy from VS. Here's a guide on doing that (you can jump right to "Publish to IIS" section if you like):
ASP.NET Web Deployment using Visual Studio
With Web Deploy, you can choose to publish directly or use a deployment package. Once you are happy the publishing works locally, you have a level of confidence your publishing will work in your Live environment.
I would suggest that before you publish direct to a live environment, that you test publish it to your local machine or a test environment that has the same IIS version, and .NET Framework installed.

TFS 2012 Team Build and Web Application Deployment - ERROR_USER_NOT_ADMIN

We have a solution consisting of several class libraries, and a Web
Application Project. We are using TFS 2012 with Team Build. The solution
compiles correctly on the build server.
I am currently trying to do this via MSBuild Arguments.
/p:DeployOnBuild=True /p:DeployTarget=MsDeployPublish
/p:CreatePackageOnPublish=False /p:MSDeployPublishMethod=RemoteAgent
/p:MsDeployServiceUrl=https://testWebServer:8172/MsDeploy.axd?site=direct /p:AllowUntrustedCertificate=True
/p:DeployIisAppPath="direct"
/p:AuthType=NTLM
The solution builds but does not deploy. I get the following error message:
msdeploy error ERROR_DESTINATION_INVALID: Web deployment task failed.
( Could not connect to the remote computer ("https"). Make sure that
the remote computer name is correct and that you are able to connect
to that computer. Learn more at:
http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_DESTINATION_INVALID.)
[C:\Builds\1\ProjectName\Solution General Build\Sources\Temp
Source\ProjectName\Solution\Project.csproj]
Is there another argument I should be passing to specify the server? I did
not intend for https to be the server name... I have tried omitting the
https:// to no avail, error is the same, so it is getting the value from
somewhere.
I have tried this with the following values for MsDeployServiceUrl:
https://testWebServer:8172/MsDeploy.axd?site=direct
https://testWebServer:8172/MsDeploy.axd
"https://testWebServer:8172/MsDeploy.axd?site=direct"
https://192.168.X.X:8172/MsDeploy.axd?site=direct
"https://192.168.X.X:8172/MsDeploy.axd?site=direct"
testWebServer:8172/MsDeploy.axd?site=direct
Update
Alright, the following is at least connecting:
/p:MsDeployServiceUrl=testWebServer
I have seen numerous posts concerning that particular argument, and almost invariably they are a URL, not just a hostname (the ones that appear to be a hostname I thought were just written that way for brevity).
I am now, however, faced with a new problem. I have made the Build Service Account (domain account) local admin on the webserver, and I am getting msdeploy error ERROR_USER_NOT_ADMIN as well as an Audit failure in the Security log.
Resolution
These are the MSBuild arguments I am currently going with.
/p:DeployOnBuild=True /p:DeployTarget=MsDeployPublish /p:CreatePackageOnPublish=False /p:MSDeployPublishMethod=WMSvc /p:MsDeployServiceUrl="https://SERVER:8172/MsDeploy.axd" /p:AllowUntrustedCertificate=True /p:DeployIisAppPath="siteName"
I am now getting ERROR_USER_UNAUTHORIZED. Apparently I have either not set up the delegation correctly or the IIS Manager User I have created is somehow incorrect. Regardless that will go in a different post if necessary.
What is the Server and IIS version, you are using?
IIS 6 uses Web Deployment Agent Service (MsDepSvc), whereas IIS 7 usually uses Web Management Service (WMSvc) which have different URLs (besides, you have to be an admin on the target server to execute MsDepSvc.
Can you try specifying
/P:MSDeployPublishMethod=WMSvc
Based on this article from Troy Hunt, Web Management Service (WMSvc) is using
.axd
URLs (the one you specify), whereas you are trying to force it use RemoteAgent publish method which seems to be inconsistent.
See this article for complete set of differencies between WMSvc and RemoteAgent publish methods.
I had a similar issue. To resolve the issue I tried the following steps:
As it was a hosted server we had to make sure that the port 8172 was open (obviously).
Creating a new login and set this up in IIS -> Deploy -> Configure -> Configure Web Deploy Publishing on the target server. I made sure that the password didn't have any spaces in to avoid the quotes issue just to be sure.
Actually running a manual deployment from the build server.
Finally specifying an IP address in the MSDeployServicerl:
/p:MsDeployServiceUrl=xxx.xxx.xxx.xxx:8172/msdeploy.axd
None of the web site names worked for me either. None of my parameters had quotes in. Of course if you leave a space in incorrectly in one of your parameters you will get the error:
MSBUILD : error MSB1008: Only one project can be specified

Use IIS as local web server to debug in my visual studio

I've an asp.net MVC website which use somme DLL that work only in 32 bits or only in 64 bits(sql lite).
Since our server are running in 64 bits, I would like to run all my code in 64 bits. The problem is that the Visual studio development server is running in 32 bits in all case.
So I come to use a Local IIS Web server.
The problem is that with an asp.net MVC website, it's mandatory to have the website at the root of the URL.
So I wish to have something like "mywebsite.lo"(with a entry in my hosts file) or "localhost:9999" as project url.
But if I try to put this, when I create the virtual directory, I got this error:
Unable to create the virtual directory. Could not find the server 'mywebsite.lo' on the local machine. Creating a virtual directory is only supported on the local IIS server.
So I created myself the website with the correct binding responding to 'mywebsite.lo'. Now if I click on Create Virtual Directory, I got a successfull message. If But when I run the website, I got a message saying : Unable to start debugging on the web server. The web server is not configured correctly. See help for common configuration errors. Running the web page outside of the debugger may provide further information.
In order to debug in visual studio with a local IIS, then Visual Studio must be running as an administrator, are you doing that?
I made a dummy mistake: The application pool was in .Net 2.x :/

Resources