views:

349

answers:

1

I have Module that is making a Response.Redirect to a different page if some condition is not met. However, I notice there are many errors in the EventLog relating to this. Am I correct that due to the dynamic loading of the Modules on the Page employed by DNN, I can't shouldn't do a Redirect in the Init method?

Here is the Exception:

System.Threading.ThreadAbortException: Thread was being aborted. at System.Threading.Thread.AbortInternal() at System.Threading.Thread.Abort(Object stateInfo) at System.Web.HttpResponse.End() at System.Web.HttpResponse.Redirect(String url, Boolean endResponse) at XXXX.Controllers.BaseNavigationController.NavigateTo(String url, NameValueCollection qsParams, Boolean endResponse) in C:\Projects\ASP_NET\XXXX\XXXX.Controllers\BaseNavigationController.cs:line 75 at XXXX.Controllers.BaseNavigationController.NavigateTo(String url) in C:\Projects\ASP_NET\XXXX\XXXX.Controllers\BaseNavigationController.cs:line 45 at XXXX.UI.DesktopModules.QuoteStepModuleBase.CheckIfOnValidStep() in C:\Projects\ASP_NET\XXXX\WebRoot\XXXX.UI\BaseClasses\QuoteStepModuleBase.cs:line 64 at XXXX.UI.DesktopModules.QuoteStepModuleBase.QuoteStepModuleBase_Init(Object sender, EventArgs e) in C:\Projects\ASP_NET\XXXX\WebRoot\XXXX.UI\BaseClasses\QuoteStepModuleBase.cs:line 31 at System.Web.UI.Control.OnInit(EventArgs e) at System.Web.UI.UserControl.OnInit(EventArgs e) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.AddedControl(Control control, Int32 index) at System.Web.UI.ControlCollection.Add(Control child) at DotNetNuke.UI.Modules.ModuleHost.InjectModuleContent(Control content) in C:\Projects\3rdParty\DotNetNuke_Community_05.01.01_Source\Library\UI\Modules\ModuleHost.vb:line 178 at DotNetNuke.UI.Modules.ModuleHost.CreateChildControls() in C:\Projects\3rdParty\DotNetNuke_Community_05.01.01_Source\Library\UI\Modules\ModuleHost.vb:line 428 at System.Web.UI.Control.EnsureChildControls() at DotNetNuke.UI.Modules.ModuleHost.get_ModuleControl() in C:\Projects\3rdParty\DotNetNuke_Community_05.01.01_Source\Library\UI\Modules\ModuleHost.vb:line 95 at DotNetNuke.UI.Containers.Container.get_ModuleControl() in C:\Projects\3rdParty\DotNetNuke_Community_05.01.01_Source\Library\UI\Containers\Container.vb:line 123 at DotNetNuke.UI.Containers.Container.ProcessModule() in C:\Projects\3rdParty\DotNetNuke_Community_05.01.01_Source\Library\UI\Containers\Container.vb:line 364 at DotNetNuke.UI.Containers.Container.SetModuleConfiguration(ModuleInfo configuration) in C:\Projects\3rdParty\DotNetNuke_Community_05.01.01_Source\Library\UI\Containers\Container.vb:line 548 at DotNetNuke.UI.Skins.Pane.InjectModule(ModuleInfo objModule) in C:\Projects\3rdParty\DotNetNuke_Community_05.01.01_Source\Library\UI\Skins\Pane.vb:line 402

+1  A: 

Response.Redirect throws a ThreadAbortException to stop the execution of the page. This is not a problem, and can safely be ignored. You might look into where you're logging exceptions, and catch the ThreadAbortException separately so that you can avoid logging it.

You can also pass false as the second parameter to Response.Redirect, which will not end the response, and not throw the exception, at the cost of rendering the page on the server when it won't be rendered to the client.

bdukes
Thank, I was aware of the fact that Response.Redirect throws an exception. I am more interested in how DNN dynamically loads modules and how it pertains to this situation. For example, is it common practice in DNN not to Redirect in the init event?
Yobi21
I've never heard any guidance from DNN to avoid redirecting in the Init event. I don't believe DNN's dynamic loading of modules has any effect on redirecting.
bdukes
We redirect in a variety of places and we use FALSE as the second parameter in response.redirect - we wondered the same thing but couldn't find any thing that says not to do it or that it was a bad practice. My 2 pennies!
codemypantsoff