Visual Studio 2017 Web publishing fails if user is non-admin while the same user can be used for VS2015 web publishing on the same web server - visual-studio

I am trying to publish a ASP.NET Core Web project to IIS (remote server) using a non-admin account using Visual Studio 2017 and I have the following error on deploy:
Starting Web deployment task from source:
manifest(D:\Projects\Own\AspNetCore\CoreWithAngularTrial\CoreWithAngularTrialApi\obj\Debug\netcoreapp1.1\PubTmp\CoreWithAngularTrialApi.SourceManifest.xml)
to Destination: auto(). C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(134,5):
Error : Web deployment task failed. (Connected to the remote computer
("...") using the Web Management Service, but could
not authorize. Make sure that you are using the correct user name and
password, that the site you are connecting to exists, and that the
credentials represent a user who has permissions to access the site.
Learn more at:
http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_UNAUTHORIZED.)
Make sure the site name, user name, and password are correct. If the
issue is not resolved, please contact your local or server
administrator. Error details: Connected to the remote computer
("...") using the Web Management Service, but could
not authorize. Make sure that you are using the correct user name and
password, that the site you are connecting to exists, and that the
credentials represent a user who has permissions to access the site.
Learn more at:
http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_UNAUTHORIZED.
The remote server returned an error: (401) Unauthorized. Publish
failed to deploy.
I have the following configuration for deployment:
Publish method = Web deploy
Server = servername:8172/msdeploy.axd
Site name = Default Web Site/CoreWithAngularTestApi
User name = username
Password = ******
The exact same configuration works when publishing a different application (ASP.NET MVC 5) under the same Web site (Default Web Site), so publishing configuration appears to be correct on the remote server.
Making username a local administrator unblocks the publishing process in Visual Studio 2017.
Also, publishing configuration files (*.pubxml) are virtually identical.
Event viewer on remote server catches the following error:
IISWMSVC_AUTHORIZATION_SERVER_NOT_ALLOWED
Only Windows Administrators are allowed to connect using a server
connection. Other users should use the 'Connect To Site or
Application' task to be able to connect.
Process:WMSvc User=username
Question: How can I enabled non-administration web publishing from Visual Studio 2017?

This issue has been fixed: https://github.com/aspnet/websdk/issues/146.
ASP.NET core project uses a different set of Publish targets (hence the change in behavior from MVC5). This project is available on GitHub - https://github.com/aspnet/websdk.

I managed to figure out why the publish fails with non-admin user. Server setup is correct, but Visual Studio publishing seems to treat ASP.NET Core Web app deployment differently from ASP.NET MVC 5 one.
I had to explicitly specify web site name within the publishing profile xml file. So, instead of:
<MSDeployServiceURL>servername:8172/msdeploy.axd</MSDeployServiceURL>
I put
<MSDeployServiceURL>servername:8172/msdeploy.axd?Site=Default Web Site</MSDeployServiceURL>
NOTE: This problem does not occur when publishing an MVC 5 project within VS2017.

Related

Visual Studio webdeploy fail even when connection is validated?

I am trying to deploy my webapp VS2015 RC1 DNX 451. Even when I validate connection and run publish I get error
Severity Code Description Project File
Error Error Code: ERROR_USER_UNAUTHORIZED
Error More Information: Connected to the remote computer ("crocus.arvixe.com") using the Web Management Service, but could not authorize. Make sure that you are using the correct user name and password, that the site you are connecting to exists, and that the credentials represent a user who has permissions to access the site. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_UNAUTHORIZED.
Error Error: The remote server returned an error: (401) Unauthorized.
Googling the issue and even trying to view host forum just says make sure username and password is correct. I am getting nowhere trying various settings. Any ideas how to debug the issue?
I am using Arvixe.com as host.
You should contact Arvixe.com. They likely have some odd configuration on their servers but I would suspect they can help you resolve the issue.
Arvixe does not support Web Deploy anymore. Once they move you to their new servers Web Deploy won't be available to you. In Visual Studio you can set up a Publish with FTP instead of Web Deploy. If you're used to Web Deploy publishing your database changes, then you'll need to do those yourself with SQL scripts. Entity Frameworks has an option to produce a SQL script for a migration, so you can use that to publish your EF database changes.

Visual studio debug access to external database

I have a question as to how the Visual Studio 2013 debug emulator for Web API works.
I had built a Web API project in Visual Studio 2013 to access a database on an external server. The code was built using VS2013's ASP.NET Web Application project template for a Web API application. Once built, running debug opened a browser window for localhost port 56618, which allowed access from Fiddler to test Http requests.
Once I had the project finished, I published it to a website using Web Deploy to IIS. However, whilst the page would open (now at localhost:9812), an http request would throw an Internal Server Error 500.
Perusing the IIS FailedReqLogFiles, I noticed that the reason that it was failing was that the database server was refusing access to '<Domain>\<machine-name>$'.
I added '<Domain>\<machine-name>$' as a valid login (windows authentication, as the connection string included "Integrated Security=true") on the sql instance with read and write privileges, and the problem was resolved.
The question is, why didn't the Visual Studio debug emulator have the same issue?
Because the emulator was running the website under the context of your own account (e.g. <Domain>\You). Your account had access to the database, so there was no issue.
When you published it to IIS, it started running under the context of a different account (<Domain>\Machine-Name - but there are other variants depending on how IIS is configured, and the version of IIS), which didn't have access to your database.

Visual Studio Web Package - doesn't appear to create full Application

I've got a .Net 4 ASP.Net application developed with VS 2012. I'm publishing the app with a publish profile set to create a Web Deploy Package, which I'll be copying over and creating on a Win2008 IIS7.3 server.
When I run the deployment script, server-side, with a "/Y" parameter, it appears to work correctly.
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe"
-source:package='C:\ReconTool\test\deploy\ReconTool.Presentation.Web.zip"
-dest:auto,includeAcls="False" -verb:sync -disableLink:AppPoolExtension
-disableLink:ContentExtension -disableLink:CertificateExtension
-setParamFile:"C:\ReconTool\test\deploy\ReconTool.Presentation.Web.SetParameters.xml"
Info: Adding sitemanifest (sitemanifest).
Info: Creating application (Default Web Site/ReconToolTest)
Info: Adding virtual path (Default Web Site/ReconToolTest)
...
But the new web site doesn't run for me - I get an 403.18 - forbidden error. When I look in inetmgr on the server for the new app, I only see the 'IIS' config section, where applications I've created manually have an 'ASP.Net' and the 'IIS' config sections.
It appears like it's not creating a full application, there are no error pages, etc, that are configured in the ASP.Net section. Wierd thing is I see the new app via appcmd as an application:
APP "Default Web Site/" (applicationPool:DefaultAppPool)
APP "Default Web Site/ReconToolDev" (applicationPool:ReconToolDevPool)
APP "Default Web Site/ReconToolTest" (applicationPool:ReconToolTestPool )
Both the Dev and Test application pools appear to be exactly the same, from what I can tell. The web.config in my Dev and Test applications are identical.
I'd appreciate any advice on additional steps I need to deploy an Visual Studio project and get it to config as an application in IIS.
Corey.

WebApi Deployed to Azure - Controllers Don't Work (500 Error)

I have a WebApi project that wraps the Dynamics CRM Online web service and provides a REST api. I have a simple controller that gets some contacts from CRM and returns them to the caller.
Everything works fine when I run it in the local emulator. However, when I deploy the project to Azure, I can reach the home page, but the controllers all return http 500 errors. Why would this happen? And how can I troubleshoot to get more details?
UPDATE
The issue is with the absence of Microsoft.IdentityModel.dll on the Server 2012 instance running the web role in Azure. I found this by opening web role instance in RDP, installing Fiddler, and making the request from Fiddler to the local IIS server. It responded with the detailed error.
Now my issue is figuring out how to enable IdentityModel on a Windows Azure Web Role. You're supposed to be able to add it via the Server 2012 Add Roles and Features wizard, but it's totally locked down on the Web Role. You can't check any boxes that aren't already checked. Is this even possible?
The issue is giving the Web Role access to Windows Identity Foundation when it's inherently not there. Marc Schweigert provides clear steps to do this here:
http://blogs.msdn.com/b/devkeydet/archive/2013/01/27/crm-online-amp-windows-azure-configuring-single-sign-on-sso.aspx
Go to the 23:00 mark of the video and you'll see the 4 necessary steps:
Reference Microsoft.IdentityModel.dll (need WIF SDK installed)
a. Set copy local = true
Create RegisterWIFGAC.cmd in your web role project
Create Startup Task in ServiceDefinition.csdef that invokes RegisterWIFGAC.cmd
Add GacUtil to the project (used in the startup task) to put Microsoft.IdentityModel.dll in the GAC every time the web role starts).

How to use MsDeploy to deploy a sub-application within a website

I have a sub application underneath an IIS website, and I can deploy it using the publish wizard in Visual Studio no problem.
However, I'm automating our deployment from our build server so I prefer to use msdeploy.exe directly.
I can deploy the main website, but trying to deploy the sub application refuses to work.
This works (www.mymainwebsite.co.uk being the IIS website):
msdeploy.exe
-source:package='www.mymainwebsite.co.uk\obj\Test\Package\www.mymainwebsite.co.uk.zip'
-dest:auto,computerName='https://testweb1:8172/MsDeploy.axd?site=www.mymainwebsite.co.uk',userName='xxx',password='xxx',authtype='Basic',includeAcls='False'
-verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:"www.mymainwebsite.co.uk\obj\Test\Package\www.mymainwebsite.co.uk.SetParameters.xml"
-allowUntrustedInfo
This doesn't (SubApplication being the application path):
msdeploy.exe
-source:package='SubApplication\obj\Test\Package\SubApplication.zip'
-dest:auto,computerName='https://testweb1:8172/MsDeploy.axd?site=www.mymainwebsite.co.uk/SubApplication',userName='xxx',password='xxx',authtype='Basic',includeAcls='False'
-verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:"SubApplication\obj\Test\Package\SubApplication.SetParameters.xml"
-allowUntrustedInfo
The error is:
Error Code: ERROR_USER_UNAUTHORIZED
More Information: Connected to the remote computer ("testweb1") using the Web Management Service, but could not authorize. Make sure that you are using the correct user name and password, that the site you are connecting to exists, and that the credentials represent a user who has permissions to access the site. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_UNAUTHORIZED.
Error: The remote server returned an error: (401) Unauthorized.
As I said, this works from the Visual Studio publish wizard, setting the Site/application property to www.mymainwebsite.co.uk/SubApplication, so I know it's not a permissions issue on the server.
Am I missing something in the msdeploy parameters?
I use the following on the command line to set the web application:
-setParam:name="IIS Web Application Name",value="www.mymainwebsite.co.uk/SubApplication"
In order to do a web deployment to sub-application of a main site, go to TFS, Deploy IIS App step, update the Override parameters to something like this
name="IIS Web Application Name",value="MainSite/SubApplication"
It should do the trick!!

Resources