Geeks With Blogs

News Awarded Microsoft MVP C#.NET - 2007, 2008 and 2009

I am born in Bangladesh and currently live in Melbourne, Australia. I am a Microsoft Certified Application Developer MCAD Chartered Member (C# .Net)and born in Bangladesh.
I am founder and Chief Executive Officer of
Simplexhub, a highly experienced software development company based in Melbourne Australia and Dhaka, Bangladesh. Co-founder and core developer of Pageflakes
Simplexhub, is on its mission to build a smart virtual community in Bangladesh and recently launched beta an ASP.NET MVC application written in C#.NET.

Some of My Articles
Flexible and Plugin based .Net Application..
Mass Emailing Functionality with C#, .NET 2.0, and Microsoft® SQL Server 2005 Service Broker'
Write your own Code Generator or Template Engine in .NET
Shahed Khan blog

I was trying to host a small DNN application in one of our Server and I was facing couple of  issues.

Problem 1:
The first problem I faced is it was always redirecting to localhost, whenever I tried it was redirecting to http://localhost/dnn as a result the site was un-accessible from outside.


This was easy to solve.
1. I needed to log in as host account.
2. Then I needed to go to the Admin > Site Settings page
3. And finally In the Portal Alias section I added a new Http Alias ""

This solved my problem when I hosted the site in port 80.


Problem 2:

Now I tried to host the application in a different port 8080. I.e. and somehow when I clicking to redirect to any other page the port started to disappear. The automatically turned to .


After googling and looking at the web.config carefully I found, its clearly documented in web.config that

<!-- set UsePortNumber to true to preserve the port number if you're using a port number other than 80 (the standard)
    <add key="UsePortNumber" value="true" /> -->


I tweaked my appsettings section  and added the magic key

<add key="UsePortNumber" value="true" />

Also I had to add a new Http Alias ""

This solved my problem and started retaining the port for my http://localhost:8080 but not  The was still turning to

Note: I later discovered this was not a problem of DNN and the issue happened because of the setup of our router settings and port forwarding, which I'll discuss next.

Problem 3: 
Even after adding the "UsePortNumber" key it did not solve my problem


Our Router was Port Forwarding all traffic of 8080 to the port 80 of the machine where DNN app is hosted. I.e. 8080 --> 80. As a result even from a browser I as typing , the DNN Request object was getting and when DNN handlers and url rewriters spitting the reformatted url it was spitting

This was a big problem for me, initially I thought I would write a HttpHandler for 404 page not found, but soon realized it will never hit the server with the spitted Url so that didn't work. Then I thought I would tweak the DNN handlers to handle this scenario, but later tweaked the IIS and Router to handle this.

1. In IIS I added, support for 8080  to my Default Website.




2. In Router instead of forwarding to port 80 I started forwarding 8080 to 8080.
3. Made sure that in my DNN Site Settings, I have added Http Alias "".

Waaa la, This solved my issue.

Hope this helps and Thank you for being with me so far.

Posted on Tuesday, February 19, 2008 5:14 PM | Back to top

Comments on this post: Solving DNN deployment issues, Redirecting to localhost and Running DNN in a different port

# Domain forwarding
Requesting Gravatar...
Thanks for being my friend.
You really put together a nice article here.
I am sure you will be an inspiration to many people.I use go daddy code all the time and it really helps to save me money while brainstorming ideas for domains. Other codes in this family include ZINE1 (Save 10% on anything), and ZINE2 (Save $5 off $30).

Left by clark on Mar 19, 2008 7:36 AM

# re: Solving DNN deployment issues, Redirecting to localhost and Running DNN in a different port
Requesting Gravatar...

I had the same problem, did this, but now it keeps redirecting to the same page, that is the main portal page: tabid=36

Any idea?


Left by Rene Vaessen on May 05, 2008 2:58 AM

# re: Solving DNN deployment issues, Redirecting to localhost and Running DNN in a different port
Requesting Gravatar...
DNN stores portal alias in the DB. Thus, to solve the problem you just need to change the db reccord in the PortalAlias table. Change the HTTPAlias field from localhost to some other (e.g.
Left by Alex on Oct 31, 2008 4:31 AM

# re: Solving DNN deployment issues, Redirecting to localhost and Running DNN in a different port
Requesting Gravatar...
Hi Thanks a lot for posting the very very usefull information related to the Redirect Loop.
Left by Shajeeb S on Jan 07, 2009 10:34 PM

Your comment:
 (will show your gravatar)

Copyright © Shahed Khan | Powered by: