Make ASP.NET the default handler for all requests

Post here for help with installing or upgrading mojoPortal pre-compiled release packages. When posting in this forum, please provide all relevant details. You may also want to review the installation or upgrading documentation.

If you have questions about using the source code or working with mojoPortal in Visual Studio, please post in the Developer forum.

Post here for help with installation of mojoPortal pre-compiled release packages

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.

You may also want to review the installation or upgrading documentation.

If you have questions about using the source code or working with mojoPortal in Visual Studio, please post in the Developer forum.

This thread is closed to new posts. You must sign in to post in the forums.
7/25/2012 5:50:06 PM
Gravatar
Total Posts 251

Make ASP.NET the default handler for all requests

Hi

I'd like to convert a static site to mojoportal, redirecting the old URLs with the builtin 301 redirector

The problem is that if I do a redirect from this url: example.com/test.html , it doesn't work, because it's directly served by IIS (=error 404)

What I can do?

Here it says it's possible to make ASP.NET the default handler for all requests, but I couldn't find how, I googled something, but it did not work...

7/27/2012 9:21:44 AM
Gravatar
Total Posts 18439

Re: Make ASP.NET the default handler for all requests

Make sure you are using an integrated application pool and make sure the <modules element in the system.webServer section has runAllManagedModulesForAllRequests="true"

Hope that helps,

Joe

7/27/2012 9:37:14 AM
Gravatar
Total Posts 251

Re: Make ASP.NET the default handler for all requests

it is already set to true (i am running in full trust)

and the app pool is integrated (and i am using extensionless urls)

7/27/2012 9:54:30 AM
Gravatar
Total Posts 18439

Re: Make ASP.NET the default handler for all requests

If that didn't work you may have to define a handler entry in iis for asp.net to handle .html as mentioned in this thread

But it may depend on whether your host enables you to make those kind of mappings.

7/27/2012 10:22:11 AM
Gravatar
Total Posts 251

Re: Make ASP.NET the default handler for all requests

It works!!!

Thanks

I didn't notice that the answer was in the documentation Imbarazzato

7/27/2012 5:58:52 PM
Gravatar
Total Posts 251

Re: Make ASP.NET the default handler for all requests

Well, it looks like I was wrong.

When I added that handler for *.htm , if I typed example.com/test.htm , I was presented with the mojoPortal 404 page, instead of IIS 404 page, so I thought it was working.

I created a new 301 redirect from Admin/RedirectManager.aspx for example test.htm => test, but if I type example.com/test.htm I still get the error 404

I added this in web.config

<handlers>
<add name="htm" path="*.htm" verb="GET,HEAD,POST,DEBUG" type="System.Web.UI.PageHandlerFactory" requireAccess="Script" preCondition="integratedMode" />

and I find this in logs:

2012-07-28 00:47:32,082 ERROR x.0.0.0 - it-IT - /home.htm - mojoPortal.Web.PageNotFoundHttpModule - Referrer(http://www.myurl.it/Admin/UrlManager.aspx) PageNotFoundHttpModule handled error.
System.Web.HttpException (0x80004005): the file '/home.htm' does not exist.
in System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
in System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
in System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound)
in System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp)
in System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
in System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
in System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

7/31/2012 3:16:59 PM
Gravatar
Total Posts 1203
Proud member of the mojoPortal team

Help support mojoPortal!
Add-on modules

Re: Make ASP.NET the default handler for all requests

I haven't attempted the route of handing HTML redirects inside mojoPortal, but on the off chance that you are running a full-blown IIS installation (rather than being hosted), you can do the redirecting from inside IIS itself, before mojoPortal even sees the request. That is how we did a similar transition from several HTML-based sites to a single mojoPortal installation.

Jamie

8/11/2012 12:52:05 PM
Gravatar
Total Posts 251

Re: Make ASP.NET the default handler for all requests

Yes, i found out that it was easier to add in the web.config keys like this:

<location path="home.htm">

<system.webServer>
<httpRedirect enabled="true" destination="home.aspx" httpResponseStatus="Permanent" />
</system.webServer>

</location>

You must sign in to post in the forums. This thread is closed to new posts.