Getting ASP.NET MVC 3 working on DiscountASP.net

On May 25, 2011, in How-to, Technical, by Frank Cheung

Getting Errors After Deploying your Application?

After deploying your application, you might see the following error message…

Could not load file or assembly ‘System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35′ or one of its dependencies. The system cannot find the file specified.

This is due to the MVC binaries not being installed in the GAC on the server. But do not fret, the GAC is optional for MVC 3! To get your application to work properly, the necessary DLLs must be published to the application’s bin directory.  Visual Studio 2010 provides a simple way to deploy the needed dlls.  Here’s how:

1) Right click on your project and click on “Add Deployable Dependencies”.  You should see the following dialog box:

2) Depending on your project, click the appropriate dependency.  Once you click OK, you should see a new folder, _bin_deployableAssemblies in your project tree.

3) Deploy your application as you normally would and Visual Studio 2010 will now deploy all the listed DLLs onto the server.

Note that you can also use the same method to deploy SQL CE 4.0 dlls.

 

Most of our customers use FTP or Microsoft Web Deploy to upload their local application to their hosting space.  In some situations, you may not be able to access your site using these methods, for instance if there are network restrictions in your workplace.

In this article, I am going to show you how to install a simple .NET file manager, FileVista, on your site.  You can use this tool to upload/download files on your site.

1.    Download FileVista from Gleamtech.  The single user license is free.
2.    On the download page, make sure you select the “Web Deploy Package.”
3.    Once you download the zip file, extract it to a temporary location on your computer.
4.    Within the extracted directory, you should see a directory named FileVista.
5.    Upload the contents to a subdirectory of your site.
6.    Once the upload process is completed, log in to Control Panel and go to the Web Application Tool.
7.    In the Web Application Tool, select the directory where you uploaded FileVista, and click Install Application.

8.    Now, navigate to the location where you installed FileVista, in this case, /filevista.  You should see the welcome wizard:

9.    Click Next.  On the next screen, you can choose whether you want to use a file based database or SQL server.  I highly recommend using the file based database unless you intended to have many users.

10.    Click Next.  You should see a Pop up displaying the preinstallation test result.  Click OK.
11.    On the next page, you’ll configure the following:

a.    Set the administrator username and password.
b.    Set the default language.
c.    Set the Root Folder.  The root folder is where the file manager will point when you log in.  If you intend to use this tool to manage your site, set the root folder to: /

12.    Click Next and you are done.  You’ll be taken to the login screen.
13.    Log in with the username/password you specified during installation.
14.    You should now see a pop-up asking if you want to use the free version or a commercial version.  Select the free license mode unless you have purchased the product.

 

WebMatrix Update Released

On March 2, 2011, in Technical, by Frank Cheung

Unlike software that includes an automatic updater that periodically checks for updates, WebMatrix doesn’t seem to have such a feature.

On Feb 18th, Microsoft released an updated version of WebMatrix which includes a number of bug fixes.  See this IIS forum post for further details.

I upgraded my WebMatrix installation as suggested in the above post.  Although the upgrade took a long time (over 10 minutes), WebMatrix worked just fine after the upgrade.  All the settings and projects are also intact.

If you have WebMatrix installed, I recommend you upgrade as soon as you get a chance.

 

orchard hostingWhat is Orchard?
In the short term, the Orchard project delivers a .NET-based CMS application that allows users to quickly create content-driven Web sites, and provides an extensibility framework that will allow developers to provide additional functionality through module extensions and themes.

In the long term, the Orchard project is a free, open source project aimed at delivering applications and reusable components on the ASP.NET platform.

You can find more information at http://orchardproject.net/

What database does the Orchard CMS require?
You can use either MS SQL Server or MS SQL CE 4 as your database.

Does DiscountASP.NET hosting platform support Orchard?
Yes, we’ve tested installing Orchard on our ASP.NET Hosting platform and it works! Your site needs to be on Windows Server 2008 since Orchard requires ASP.NET 4.0.

How do I install Orchard?
Manually: You can install Orchard manually by uploading the files. Here’s a link to documentation: http://www.orchardproject.net/docs/Manually-installing-Orchard-zip-file.ashx

WebMatrix: You can deploy Orchard using WebMatrix. You may want to use our new Web Deploy Publish Settings Generator in the control panel. We have a new knowledge base article on deploying apps with WebMatrix too.

Control Panel Web App Gallery: We’ve added Orchard to the Control Panel Web Application Gallery available to customers on our Windows 2008 hosting platform for an easy one-click deployment!

Orchard Resource links:

http://www.orchardproject.net

http://orchard.codeplex.com

Frank Cheung
CTO

 

For certain applications, you might need to write/modify files on your site, e.g., logging, file based database, etc.  Recently, we have seen some customers reporting an access denied error when their application tries to write/modify files within their website.

We found that when you deploy your website using the WebDeploy feature of Visual Studio 2010, the deployment package actually contains couple of SetAcl rules

  1. change the aspnet user to only have read access.
  2. Change the aspnet user to have change (RW) access to the app_Data directory

This means that if the file you are trying to change is not within the app_Data directory, you’ll get an access denied error.

In theory, this concept is good because it makes your site more secure, however, there are some problems associated with it.

  • You cannot tell VS.NET to change the rule to allow write permission to directory other than app_Data.  As a result, you will need to rewrite your application to store the updatable file within the app_Data directory.
  • There’s no UI configuration to tell VS.NET to not mess with permission on the server

So…what do we do?

After some research, it looks like you can configure VS.NET to not change the NTFS permission when deploying using webdeploy.  The process is not very straightforward, but works nonetheless:

  • Open your project file (.csproj or .vbproj) in notepad or any other text editor
  • Navigate to the proper property group (you get one node for each compile configuration)
  • Within this element
    • <propertygroup condition=” ‘$(Configuration)|$(Platform)’ == ‘Release|AnyCPU’ “>
    • Add <includesetaclproviderondestination>False</includesetaclproviderondestination>
    • You’ll need to add this line for each configuration that you want SetAcl disabled.
    • Save the project file
    • Reopen it with VS.NET
    • Note that by adding this, it will not “Fix” the permission on the server.  If any previous deployment changed the permission, you’ll have to contact our support team to reset the permission.

I am sure Microsoft will make some enhancements to VS.NET in the future releases.  In the meantime, you’ll have to use this rather tedious workaround.

Frank Cheung
CTO

Tagged with:  
iBlog by PageLines