This project is read-only.

Any way to NOT use URL Rewriting?

May 29, 2009 at 5:20 AM

I'm trying to get BlogEngine up and running in a shared hosting environment.  I only have one application folder and have BlogEngine installed in a subfolder of the application.  Getting the app running in this scenario required a few tweaks, and it is running great except that I can't get the URL rewriting to work.  This means all of my direct post links (and possibly other things I haven't found yet) result in redirection to error404.aspx.

Having written URL rewriting modules and the apps that use them, I suspect that the issue is that the "Check File Exists" option for the application in my shared hosting environment is turned on.  Getting this changed through my provider will be only slightly more pleasant than having teeth pulled.  Is there a setting to change to make post links use the permalink format (Post.aspx?Id=[GUID]) instead of slug URLs?  Similarly, is there any way to make feeds work without URL rewriting?

Thanks in advance!

May 29, 2009 at 7:32 AM
Edited May 29, 2009 at 8:51 AM

Are you using GoDaddy, by chance?  A number of people here have had problems with the way GoDaddy does URL rewriting when BE is installed in a sub-folder.  I think the problem there is more when you're using a subdomain (not sure though).  They may not be the only host that has this problem ....

Unfortunately, there's not a setting to turn URL rewriting off.  You could modify the BE code to do it.  It shouldn't be that much work.  For example, the URL for posts comes from the RelativeLink property in the Post class.  Making a change in that one place would let you use a different URL for all the posts.  You'd then want to modify the UrlRewrite module.  A 3rd change that comes to mind is modifying the post.aspx.cs file that does a redirect to the rewritten URL if a request comes in with the GUID in the querystring.  Recompiling the core code would be necessary.

Having a setting might be nice, but compared to some of the other custom modifications people here want to do, the modifications for this aren't that big of a task.

May 29, 2009 at 1:40 PM

Thanks for the quick reply.  I'm using Network Solutions as the host and have multiple domains hosted with a single hosting package.  The web root for the hosting package is the root of the single .NET application and I have all domains pointed to subfolders under the application root.  In general, their support has been good in the 10(!) years I've been hosting sites with them, but explaining the "Check File Exists" setting in IIS and getting it changed would probably be more work than changing BlogEngine.

I'll probably make two changes to the application. The first will be to add a couple appSettings to support the "in a subfolder" operation.  The three main problems there are:

  1. Moving some web.config settings from BlogEngine web.config to application's web.config.
  2. MasterPageFile attributes in Page directives use "~/" and not virtual root appSetting.
  3. User control imports on some pages use "~/" and not virtual root appSetting.

For #1, is there a good place for me to post documentation on how to accomplish that?  As for #2 and #3 and the Url Rewriting issues,  I think all are easily remedied by some minor code tweaks as well.  If I were to make those changes, is there a way for me to submit them for inclusion in a future release? 

May 29, 2009 at 8:19 PM
Edited May 29, 2009 at 8:23 PM

There's two options to get BE running in a sub-folder that shouldn't require any coding changes to BE.

OPTION 1:  Mark the BE sub-folder as an application starting point in IIS.  This is the simplest option and supported at a good number of hosts.  In this case, the sub-folder is its own application.  You wouldn't need to merge any of the BE files into the root of your site.

OPTION 2:  If option 1 isn't possible or undesired, put some of the key BE files into the root folder.  Specifically,

1. The BIN folder files should go in the root BIN folder.

2. The App_Code folder files should go in the root App_Code folder.

3. The App_GlobalResources folder files should go in the root App_GlobalResources folder.

4. The App_Data folder files should go in the root App_Data folder.

5. The Global.asax file should go in the root folder (may need to merge w/existing global.asax file).

6. Web.sitemap can maybe remain in the sub-folder.  If you don't already have a Web.sitemap in the root folder, you can just put BE's web.sitemap in teh root folder.  Otherwise, there's a "siteMap" element in the BE web.config file you can use to possibly have more than one web.sitemap file.

7. Web.config file of BE needs to be merged with web.config file in the root folder.  This isn't too difficult.  The parts of the BE web.config file you would want to move into the root web.config file would be:

(a) <configSections><sectionGroup name="BlogEngine">
(b) <BlogEngine>
(c) <appSettings> - the 6 or so settings
(d) <authentication>
(e) <pages><controls>
(f) <membership>
(g) <roleManager>
(h) <siteMap>
(i) <httpModules>
(j) <httpHandlers>
(k) <system.webServer> - if using IIS7.

Also important, the default value for the "BlogEngine.VirtualPath" appSetting is "~/".  Changing that to "~/BlogEngineFolderName/" will tell BE to create URLs with the BlogEngineFolderName in the path.

The above isn't an exact "recipe".  Merging the BE files into an existing site is going to depend on what you already have in the existing site.


If your host doesn't allow you to create multiple application starting points, and also has IIS setup to require files with an extension of AXD and ASPX to exist, that doesn't sound like a very good host, IMHO.  I have BE at a couple of different hosts where I just put it in a sub-folder and mark the folder as an application, and I'm all done.  Making the change in IIS to not require a physical file to exist for a file extension only takes a minute to do.

May 31, 2009 at 3:27 AM
Edited May 31, 2009 at 3:53 AM


I too use Network Solutions as my hosting provider. I agree with you that their support is generally very good, but sometimes its just easier to do things yourself!

I found that by using Account Manager to install the older version of BlogEngine.NET will set up the server to allow for ASP.NET 2.0 Applications. You can install the older version by going to WebHosting -> Manage Web Hosting -> Toolbox ->Site Enhancements -> Open Source Applications in the Network Solutions Account Manager. From here you can install the older version of BlogEngine to any directory in your hosting account. This will also create an IIS Application on the directory,  You can then upload the newer BlogEngine.NET version or any other .NET app you like.

I hope this helps.


Jun 1, 2009 at 2:09 PM

The sound you hear is the sound of my hand slapping my forehead!  I've never noticed that section of installable apps before.  I already had BlogEngine up and running properly (with the exception of URL rewriting) but I think I'll take your approach to get the application setup.  I imagine that it only creates one instance of BlogEngine. i.e. You can't use it as a shortcut for multiple apps. 

Thanks to you guys for responding so quickly!

Jun 1, 2009 at 2:20 PM

And for those wondering why I'd rather rewrite the app than to pursue changes through NS.  There is the thread from their support forums.  Perhaps my original post did not describe the issue, but I'm pretty sure I didn't ask anything about the error page. I do suppose I could be clever with 404 handling using a custom page that parses out the desired URL and looks up the proper PostId and such. 

In the reply, I'm impressed that the guy actually looked at my account, though he didn't note that child folders already override the error mode setting in their own web.config files.


My Post:
QUOTE (FatNoah @ May 29 2009, 01:01 AM) *
<!--quotec-->I am trying to deploy an application that uses URL rewriting. Specifically, I have an HTTP module is registered in the web.config that looks at a request for pages and "rewrites' the requests to go to another page.

For example, the URL for a blog post is really Post.aspx?id=[SOME_GUID], but with URL rewriting I can create a link to a non-existant ASPX page such as MyFirstPost.aspx that is more "user friendly." Even though this page doesn't exist, users going to the page won't get a 404 because the url will be rewritten to Post.aspx?id=[SOME_GUID].

The problem I am having is with an IIS setting that isn't configurable through the web.config for IIS 6. This setting tells IIS to verify that file exists before handing the request off to the ASP.NET ISAPI. It appears this setting is On, which means that requests for my "user friendly" URLs are not passed on to ASP.NET by IIS.

Fixing this is simply a matter of unchecking a box in an IIS application configuration screen, but does anyone know if Network Solutions will make such a change? If so, does anyone have any suggestions on how to phrase my request so that the support tech handling it will know what I'm asking?



The Reply:


Actually, this is already enabled, and you can make custom 404 pages using web.config.

Your specific issue is caused because of line 45 in your web.config

<!--ec1--><customErrors mode="Off"/><!--c2-->

Change this to point your specific custom error page and it will work.

<!--ec1--><customErrors mode="On">
              <error statusCode="404" redirect="/kristenandnoah/error404.aspx" />

I see you're trying to have different custom error pages for different folders, and this may be where your frustration is coming in. Except for applications that were auto-installed from within the Open Source section of the Hosting Manager, we only support one .net application per hosting package, and it must be located in the /htdocs folder.

You may need to be more creative with your error.aspx script if you are looking for an error page that varies depending on URL used. <!--IBF.ATTACHMENT_19013-->