Site hosting news, tutorials, tips, How Tos and more

Latest Posts from Ray P.


How to stop Web Deploy/MSBuild from messing up server permissions

howto

Web Deploy is a fantastic tool to publish your web site to a remote web server. It’s easy, quick, secure, and configurable. However, Web Deploy in conjunction with Visual Studio or in conjunction with MSBuild can alter the account’s permission on the production web server. This is by design. Microsoft believes that a web site is more secure when the web application itself is set to read-only permission. But a lot of functionality is lost with read-only permissions.

First off, let me explain the nature of the problem. Every web site that is hosted on an IIS server will have a specific user to authenticate against the server. The Account Control List will typically have an Anonymous ASPNet IUSR. This is standard for all default web sites. The server does not have to use this user, you can create your own user for the web application to run correctly but let’s stay with the “standard” setup.

Typically the Anonymous ASPNet IUSR will have Read and Write permission to the root and all of the files and subfolders under it. But when you use Web Deploy with Visual Studio or use the MSDeploy command, Microsoft Web Deploy will alter the permission of your Anonymous ASPNet IUSR to have only Read permission. That means any ASP.Net functionality that will perform an upload, file creation, or file modification will fail due to lack of Write permission.

To be honest, Web Deploy itself does not technically alter the permission on the server but one of the properties in MSBuild. So if you use Web Matrix in conjunction with Web Deploy, this is not an issue because Web Matrix does not use MSBuild; Visual Studio does use MSBuild, so with Visual Studio and Web Deploy you can get your permissions skewed.

It is worth noting that if you web deploy your web application to a subfolder this may not be an issue. The reason being is the “Inheritance” feature with NTFS. If the root folder has Read and Write permission, Inheritance will take precedence, and when Web Deploy tries to alter the permission on the subfolder level, the NTFS inherited properties on the root will revert it back to Read and Write. If you decide to Web Deploy directly on the root, then the root folder permission will be altered to Read-only permission and that will get inherited down to the subfolders within that root.

Confusing, I know, but stick with me here. So what is the solution?

There are several ways to fix this problem. One is to get access to the server and reset the permissions manually. If you are using a shared web hosting provider, you’ll need to contact their system administrators to reset it for you. The problem with that is if you use Web Deploy to publish your web application again, then they’ll need to reset the permissions again.

A more viable solution is to alter your project file to prevent Web Deploy from altering the ACL on the remote web server. To accomplish this, simply navigate to your project and find the file with the extension .vbrpoj. If you created your project in C Sharp, look for the project file .csproj. This is outlined in this Winhost Knowledge Base article.

There are still some drawbacks to this. One of the biggest drawbacks and one that tends to confuse developers is where to place the element line in the project. The line you will need to add to your project is

<includesetaclproviderondestination>False</includesetaclproviderondestination>

The project file is grouped to different sections, and you will need to find the section

<propertygroup condition=” ‘$(Configuration)|$(Platform)’ ==’Release|AnyCPU’ “> </propertygroup>

That is where you will include the <includesetaclproviderondestination> element.

Some developers have not been able to get this solution to work. That is due to the ‘Release|AnyCPU’ setting. This setting is for the Configuration and Target Platform. As early as Visual Studio 2005, Microsoft has included the ‘web.config’ Transformation feature. This allows you to create specific elements and values to a web.config file base on the environment. Specific elements may only be suitable for the development environment while the production servers may have different attributes and settings. So depending on how the final build of the project is performed, the project configuration could either be taken from the ‘Release|AnyCPU’ or ‘Debug|AnyCPU’.

If you placed your <includesetaclproviderondestination> within the ‘Release|AnyCPU’ section but built your project within the Debug configuration, then the <includesetaclproviderondestination> attribute may not invoke on the production server. To make sure your permission is not altered create the <includesetaclproviderondestination> attribute on both the ‘Release|AnyCPU’ and ‘Debug|AnyCPU’ group of your project file.

Keep in mind that any for new projects you create, you will need to run through these steps again to keep Web Deploy/MSBuild from altering your permission on the production server. A more permanent solution is to alter the MSBuild publishing settings on your development computer. This will help ensure that any ASP.Net project you create in the future on that specific computer will not alter the permission on the web server when deploying with Web Deploy.

Achieving this is fairly simple and it is a one-time change:

The file you will be modifying is the Microsoft.Web.Publishing.targets file. In Notepad, search for the <includesetaclproviderondestination> element. By default the value is set to True. Set it to False and from that point forward, any ASP.Net projects you create with Visual Studio and initialized the Web Deploy method will not alter the Anonymous ASPNet IUSR’s permission.

Remember, if you are planning to alter and save the Microsoft.Web.Publishing.targets file, you must run Notepad as an administrator.



Using MSDeploy to publish your site

howto

One of the most daunting tasks a webmaster must perform is uploading a large web site to a remote web server. Depending on your Internet connection speed, the task can be tedious as files are uploaded to your root directory one file at a time. If you have 10 or 20 files this is not a big deal. But what if you have hundreds or thousands of files to upload? The files can range from code behind files, to images, audio files, DLL files and more.

Luckily Microsoft has introduced a solution to this problem with MS Web Deploy.  Web deploy can be used with IIS 7, Web Matrix, Visual Studio, or through the command prompt MS DOS.  The first thing that you will need to do is download MSDeploy.  This is the tool that will help you package or zip your web site.

Run through the installation wizard to install the “Web Deployment” tool on your computer. You do not need IIS 7 for this.  Although Web Deploy and IIS 7 can work side by side, the Web Deployment Tool can run independently. You can install and run this on Windows 7, Vista, or XP without setting up your own local web server.

One thing you do need to install is the “Remote Manager Service.”  This should be part of the Web Deployment Tool installation Wizard, but by default the installation does not install it, therefore you will have to manually install it.

The installation will install the MSDeploy command. This command can be invoked using the MS DOS command prompt.  One thing you need to be aware of is that MSDeploy requires administrator rights to run properly. The easiest way this can be done is to navigate to MS DOS using Windows Explorer.  Go to C:\Windows\System32 and right click on CMD.EXE.  Choose “Run as Administrator”.

Once the command prompt is up, you will navigate to the folder level where MSDeploy.exe exists. On Windows 7, the default installation will place msdeploy.exe in C:\Program Files (x86)\IIS\Microsoft Web Deploy.

msdeploy.exe has an extensive command base. Typing [MSDeploy /?] in the command prompt will yield a large selection of commands and conditions you can run. There are two core tasks that MSDeploy can be used for. One is Archiving and the other Packaging. The two are different and each have their own unique properties.Compare Winhost plansFor zipping files and publishing to a remote IIS web server, you will be using the Package Provider. Archive is mainly used for backing up your site for safe storage, where as the packaging method zip up the files for you. For a list of provider settings, you may want to look at this Microsoft site to get your feet wet.

To get started deploying your site with a zip file, one thing you need to know is that you cannot simply use your OS compression tool to zip a website. You will need to use MSDeploy for that.  When MSDeploy zips a file, it will also create a couple of xml files. These files are archive.xml and systemInfo.xml. These files describe the properties of your web application. You will need these files to deploy to an IIS server with MSDeploy.

Technically you can manually create these files and then manually zip. However, creating these files from scratch is much more complicated than running MSDeploy. To properly zip your web site, you will first need to navigate to the folder where msdeploy.exe exists. The path to MSDeploy should be C:\Program Files (x86)\IIS\Microsoft Web Deploy V3. Once you are there, run this command in your MSDOS command prompt:

msdeploy.exe -verb:sync -source:iisApp=”C:\ Test_site\Website” -dest:package=c:\Test_site\testsite.zip

You will need to use the provider iisApp so that MSDeploy will know the destination folder will be an application folder. If you are uploading to the root it shouldn’t be a problem since most IIS root folders are already set as an application folder. But if you are going to upload it to a subfolder, zipping the files with the iisApp provider will be important.

Bear in mind that the paths I am using are examples, and it will be up to you to determine the path where your website exists and the path where you want to place the zip file. Once this is done, you can run the MSDeploy command against your remote IIS server:

msdeploy.exe -verb:sync -source:package=”c:\Test_site\testsite.zip” -dest:iisApp=”domain.com/subfolder01″,
wmsvc=domain.com,username=IIS_username,password=IIS_password,
skipAppCreation=false -allowUntrusted=true

The “skipAppCreation” command forces a subfolder to be created as an application folder. By omitting this command the default value will be “true.” If you are uploading directly to your root, you do not need to define this value. You will need to use the iisApp provider as your destination. Otherwise, MSDeploy will not know how to connect to the remote IIS server.

Lastly, the target server where you will be placing your packaged file and uncompressing it will need to have Remote Manager Services installed. Without you will not be able to publish your site with MSDeploy. In addition to that, the MSDeploy (Web Deploy) tool is only for Microsoft platforms. From what I’ve read it will work on an Windows XP, Windows Vista, Windows 7, and even Windows Servers such as Windows 2008. It is not compatible with non-Microsoft platforms such as Linux or Mac.



How to work around an annoying SQL Management Studio Designer error

howto

This may be an old topic but it’s worth mentioning.

Ever since SQL 2005 was released, there is a weird setting in SQL Management Studio that prevents you from saving the changes on your database.  The error is very misleading because it gives an impression that the security error is coming from the SQL Server itself, when in fact it’s your SQL Management Studio that is generating the error.

I was hoping this would be fixed in SQL 2012 Management Studio, but it still seems to exist.

This is the error you will see in Management Studio:

Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created.

What will lead to this error is when you create a table, save it, then go back into the table and impose changes such as setting auto increment on a specific column.

The reason is because these types of changes will actually cause Management Studio to delete the table and recreate it.  This is done behind the scenes by SQL Management Studio.  So I guess SQL Management Studio wants to make sure it has permission before making such life altering changes.

Odd right? Fortunately the fix is really easy.  In SQL Management Studio (it does not matter whether you are connected to a database or not) go to Tools/Options/Designers/Table and Database Designers.  Make sure you uncheck “Prevent saving changes that require table re-creation.”

Now keep in mind, I’m using SQL 2012 Management Studio, but I believe this should be the same for the older SQL Management Studios, such as 2005 and 2008.  And as you can see, since I do not need to connect to the SQL Server to make this change, the setting is associated with Management Studio, not the SQL Server itself.



Holding Domain Names Hostage

howto

I’ve been reading that some registrars make it difficult for a person to leave them. That once you register your domain name, they will do almost anything to keep you. There may be a good reason why you want to jump ship and have your domain name registered with a different registrar. It could be for price, convenience, or simply better support. Regardless of the reason it should not be “rocket science” to change your registrar.

dog

Now, I’m not here to insult anyone, but what I want to make it clear that Winhost has made every effort to allow customers who register their domain name through us to move to another registrar if they wish. Before we proceed with the steps—and you may be surprised how simple it is—let us run through a preliminary check list.

Everyone should check this list before attempting a registrar transfer, regardless of what registrar you are with.

Preliminary Checklist

    1.  Check and verify who your registrar is.  Use this link: http://www.networksolutions.com/whois/index.jsp. I know this sounds like a waste of time, but I can’t tell you how many times people will argue with a hosting provider only to find out that they were never the registrar.
    2. Check whether you have whois privacy enabled.  If it is enabled, you will need to make sure you disable it. Whois privacy or Private Domain Registration is a service that allows a person to keep certain domain name information private. Information such as Billing, Administration, and/or Technical Contacts. Some people don’t like their information to be available on the Internet. By purchasing Private Domain Registration, when someone does a whois look up of your domain name, all they should see is the registrar name, the name servers the domain is pointing to, and the domain name expiration date.
    3. Make sure that the email address on record with the registrar is valid and active. This is very important because during the course of the transfer, transfer approval emails will be sent to the email addresses associated with the domain name. Verify that your Administrative and/or Technical contact information is up to date, and the email address is valid and active.
    4. Last but not least, you’ll need to verify that the domain name has not been registered or renewed within the last 60 days. This is a standard requirement and can be checked by pulling up the whois record and checking the Expiration and Modified date. If you have just registered the domain name or renewed it within the last 60 days than you cannot transfer it. Some registrars will forbid you to transfer your domain name to another registrar if you simply update the contact information on your domain name. Winhost has no such limitation. Our only condition is the 60 day registration/renewal window.

Now that you’ve gone through the list, transferring a domain name away from us should be fairly easy.  Oh, before I forget, make sure you have selected a registrar that you will be transferring the domain to.  You will need to set up an account with them before you initiate the transfer. Each registrar has their own steps for registering so I’m not going to go over them in this article.

Here are the steps to transferring a domain name away to another registrar:

    1.  Log into the Winhost control panel and click on the “Domains” tab.
    2. In the “Whois Record” column, click the “View/Edit” link.  This will take you to the domain name’s personal information (Contact, Administrative, and Billing information). From here you can disable Whois Privacy if it is enabled, and you can also update the name servers if you wish to point it somewhere else.
    3. Back in the Winhost control panel/Domain Manager, click on the “Unlock” link in the “Move Away” column. Unlock your domain name, and you will be given the Authorization Transfer Code; also known as the EPP Auth Code. You will need that code when you  initiate the transfer at your new registrar.
    4. Go to your new registrar and go through the steps to initiate a registrar transfer to them.

That should be it. Pretty easy, right?  If anything goes wrong, check with the new registrar to see where the process may have failed. Check your email address in the whois information, and lastly you can always open a ticket to Winhost support to see if anything is stopping the registrar transfer on our end.


While this article has been about how to move your domain away from Winhost, we do hope that you will continue to use our hosting services. We think we provide the best hosting value available anywhere. You may be able to find a lower price, but one thing you will not find at the cut-rate hosts is our level of service and commitment to quality. Those are things we live and breathe, we don’t just talk about them.

If you are at one of those lowest-common-denominator hosts now and you want to come join the Winhost family, stay tuned for an upcoming article on painless host transfer. Yes, it is possible!



Beware the IDE Browser View Mode

howto

There are a lot of developers out there that create and test web applications on their local computers.  For the most part things are done correctly and everything on their end seems to be correct.  But when they upload or publish it to their hosting service, they get errors and all sorts of different problems.  This can leave a developer confused and scratching their heads.  They go back to their computer, check the code, and everything looks correct.  Then they run their web application on their computer and it pulls up nicely.  No errors and no hint of anything are wrong with the application.  Yet when they publish the files to the web server, it doesn’t work.

Why?

I believe the problem lies in the IDE the developer is using, namely Visual Studio and Web Matrix.   These IDE have a feature that allows you to run your application and view it on your browser directly.   It is commonly known as View in Browser Mode.  Developers use it to quickly debug their web applications and find potential coding problems before they deploy to production.

But these features run off on their own engine behind the scenes.  For the most part they are a great tool to see how the site will be displayed in the browser.  But for more complex applications such as MVC applications, it can be very misleading.

When you use these tools, the IDE engine that will render the site automatically plugs in all the required assemblies and components, thus giving you a false perception that the application is fully functional.  But when you upload it to a hosting web server, the assemblies and components needed to run the application are not attached with the deployment unless you manually set them to be.

If you really want to test your web application before you deploy it to a production server, install IIS Server on your computer.  For Windows 7 and Windows Vista, it already comes with IIS, you merely have to enable it.  The application can be enabled in Control Panel/Programs/Turn Windows Features On/Off.  Scroll down and install all of the IIS components.  IIS stands for Internet Information Services, and it is the application that Microsoft uses to publish a web site.  The root will be created under C:/Inetpub/wwwroot.  Copy your test site into that folder and in your browser type; http://localhost.  IIS will automatically serve it to you just as a production web server would.

You will be surprised to see that it may generate an error, while the View in Browser mode in your IDE it is displayed without any problem.  This is a tell-tale sign that something is missing, and if your IIS web service cannot render the page correctly on your local computer, you can be fairly sure it will not be rendered correctly on a web hosting production server.