Showing posts with label iis. Show all posts
Showing posts with label iis. Show all posts

Thursday, June 3, 2010

Move Google Apps Domain To DiscountASP.NET

Tonight I signed up for web site hosting plan with DiscountASP.NET. Partially forced to because Google was indexing by blog at blog.cdeutsch.com as cdeutsch.com (due to the way I had Google Apps configured, D'oh!), but I also want to do some experimenting with ASP.NET MVC 2 and play around with some custom iPhone web services.

DiscountASP.NET wants you to point your domain at their nameservers for their hosting to work. This is kind of a bummer since I was happy with Google Apps handling that. The good news though is this CAN be done! I figured out how to do the CNAMES myself and had been smart enough to write down the info I needed before switching nameservers. Unfortunately I didn't write down the MX Records but with help from Steve Trefethen's blog I was able to fix them. My settings are below:

CNAME Record Manager
Canonical Name Record: Creates an alias from one hostname to another.
Use of CNAME is generally not recommended.
Domain NameDestination TTL

blog.cdeutsch.com


ghs.google.com

3600

calendar.cdeutsch.com

ghs.google.com


3600

docs.cdeutsch.com

ghs.google.com

3600

mail.cdeutsch.com

ghs.google.com

3600

sites.cdeutsch.com

ghs.google.com

3600


start.cdeutsch.com

ghs.google.com

3600






MX Record Manager 
Mail Exchanger Record: Identifies the email server that handles email for a domain.
Domain NameDestination DistanceTTL

cdeutsch.com

ASPMX.L.GOOGLE.COM

10

3600

cdeutsch.com

ALT1.ASPMX.L.GOOGLE.COM

15

3600

cdeutsch.com

ALT2.ASPMX.L.GOOGLE.COM

15

3600

cdeutsch.com

ASPMX2.GOOGLEMAIL.COM

20

3600

cdeutsch.com

ASPMX3.GOOGLEMAIL.COM

20

3600

cdeutsch.com

ASPMX4.GOOGLEMAIL.COM

20

3600

cdeutsch.com

ASPMX5.GOOGLEMAIL.COM

20

3600







The second part of my mission was to redirect www.cdeutsch.com to just cdeutsch.com. Due to DiscountASP.NET's awesomeness they support II7 and the IIS Rewrite extension so this is super easy. Just update your web.config with the following:

<system.webServer>
 <rewrite>
  <rules>
   <rule name="Canonical Host Name" stopProcessing="true">
    <match url="(.*)" />
    <conditions>
     <add input="{HTTP_HOST}" negate="true" pattern="^cdeutsch\.com$" />
    </conditions>
    <action type="Redirect" url="http://cdeutsch.com/{R:1}" redirectType="Permanent" />
   </rule>
  </rules>
 </rewrite>
</system.webServer>


Or if you want to do the reverse (cdeutsch.com to www.cdeutsch.com) :

<system.webServer>
 <rewrite>
  <rules>
   <rule name="Redirect to WWW" stopProcessing="true">
    <match url=".*" />
    <conditions>
     <add input="{HTTP_HOST}" pattern="^cdeutsch.com$" />
    </conditions>
    <action type="Redirect" url="http://www.cdeutsch.com/{R:0}" redirectType="Permanent" />
   </rule>
  </rules>
 </rewrite>
</system.webServer>

Now that I had that working I needed some content. What better way to start then with a fresh ASP.NET MVC 2 website. I started with the basic template built-in to Visual Studio 2010. You'll need to go to your project's References and click "Properties" on the "System.Web.Mvc.dll" and change "Copy Local" to "True" to get MVC to work on DiscoutASP.NET's servers. More info here. You'll also want to make sure you configured your web application to run using the .NET Framework 4.0. Framework 3.5 will work for MVC 2, but in my control panel it defaulted to Framework 2.0 and was throwing errors. When I went to fix it the only other option I saw was 4.0, it's possible there is a 3.5 settings somewhere, if there is feel free to try that too:  UPDATE: after talking to Michael Maddox I realized the errors I got were probably because I had my solution/project targeting 4.0. So you can either do the steps below if your project is for 4.0, or change your project to target 3.5 and then you can skip this step.
  • In your Control Panel go to "IIS Tools"
  • Under the "ASP.NET Version" tab set the version to "4.0".
  • Make sure after you hit "Update" you read the warning and click "Update" (or whatever it says) again.
If you found this helpful and you're going to sign up for DiscountASP.NET, please use my referral code: CDEUTSCH