ASP.NET testing shortcut

I often find when developing an ASP.NET application that I want to set a number of variables when the application loads to make testing easier. I usually have a number of variables set in the Session_Start section of the global.asax.vb or in the Page_Load of the default.aspx page. This is a quick and easy way of setting things like the currently logged in user or other settings.

The problem with doing this is that if you forget to comment out or remove these entries prior to uploading the site live you can run into some rather large problems.

If found an excellent function in the Request.URL class that can help avoid this issue. The function is called IsLoopback. If you wrap  “If Request.URL.IsLoopback” around your variable setting code, it will only be run when you are running your code from within Visual Studio or from IIS using the http://localhostURL.


Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
     ' Fires when the session is started      Session(SessionVariables.UserID) = 1      Session(SessionVariables.CustomerID) = 2 End Sub


Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
     ' Fires when the session is started
     If Request.URL.IsLoopback Then
          Session(SessionVariables.UserID) = 1
          Session(SessionVariables.CustomerID) = 2
     End If
End Sub

As you can see from the code, if you forget to remove or comment out this code when you upload it to your web server, the code will skip right over setting these variables.

I would only recommend this type of variable setting in the initial development/testing phase and it should be removed once your application is put live.

Resetting a DotNetNuke Host user password

A frequent question asked by customers is how to reset the DotNetNuke Host users password if you can’t remember what it is.
If you have access to the database this is a fairly easy process.

Steps to reset a DNN Host password

  1. If you do not know the database details of your DNN database, login to your account via FTP and view the web.config file in the root of your DNN application. You can get the Server name, db name, username and password from the connectionstring property.
  2. Open SQL Management Studio and connect to your SQL Server using the information from step 1.
  3. If you have set your registration to none, private or verified then you’ll need to edit the Portals table and change the UserRegistration field to 2. This will set the registration setting to Public.
  4. Open your site and click on the register button, then register a new user.
  5. Open the Users table and find the record of the new user you just added at the bottom. Set the IsSuperUser field to True (or 1 for SQL 2000).
  6. Login as your newly created user and you should see the Host and Admin menus. Click on the Host, Host Accounts link then click on the All link on the user list.
  7. You should now see the Host user listed. You can click on the pencil edit button on the left of the user to reset the Host users password.
  8. If you no longer need the newly created user you should logout and log back in as Host and delete it. You can then also login as Admin to your portal and set your registration setting back to what it was previously.