Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0SecurityPermission Exception on NavigateUrl()SecurityPermission Exception on NavigateUrl()
Previous
 
Next
New Post
9/27/2006 3:13 AM
 

Hi guys,

First of all, sorry for the long post.

I'm having a problem with a custom module. At the moment we're creating a bunch of custom modules and coming across the following Exception on a redirect in the first one:

A critical error has occurred.
Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

A look into the Log Viewer shows a Page Load Exception with the following details:

RawURL: /[PageName]/[PageName]/tabid/53/ctl/Edit/mid/375/Default.aspx
AbsoluteURL: /Default.aspx
AbsoluteURLReferrer: http://[URL under NDA]/[PageName]/[PageName]/tabid/53/ctl/Edit/mid/375/Default.aspx
UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)
DefaultDataProvider: DotNetNuke.Data.SqlDataProvider, DotNetNuke.SqlDataProvider
ExceptionGUID: a2bf43de-1927-491d-8fa1-c8ac2caa28ab
InnerException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
FileName:
FileLineNumber: 0
FileColumnNumber: 0
Method: System.Threading.Thread.ResetAbort
StackTrace:
Message: DotNetNuke.Services.Exceptions.PageLoadException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. ---> System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. at System.Threading.Thread.ResetAbort() at DotNetNuke.Services.Exceptions.Exceptions.ThreadAbortCheck(Exception exc) at DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(PortalModuleBase ctrlModule, Exception exc) at C4Communication.Nuke.Modules.Sport.Codes.EditCode.Update_Click(Object sender, EventArgs e) at System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) The action that failed was: Demand The type of the first permission that failed was: System.Security.Permissions.SecurityPermission The first permission that failed was: <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlThread"/> The demand was for: <PermissionSet class="System.Security.PermissionSet" version="1"> <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlThread"/> </PermissionSet> The granted set of the failing assembly was: <PermissionSet class="System.Security.PermissionSet" version="1"> <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true"/> <IPermission class="System.Security.Permissions.IsolatedStorageFilePermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Allowed="None" UserQuota="1048576"/> <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Execution"/> <IPermission class="System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Level="Unrestricted" Unrestricted="true"/> <IPermission class="System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true"/> </PermissionSet> The refused set of the failing assembly was: <PermissionSet class="System.Security.PermissionSet" version="1"> <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode"/> </PermissionSet> The assembly or AppDomain that failed was: C4Communication.Nuke.Modules.Sport.Codes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null The method that caused the failure was: Void Update_Click(System.Object, System.EventArgs) The Zone of the assembly that failed was: MyComputer The Url of the assembly that failed was: file:///e:/inetpub/afl/bin/C4Communication.Nuke.Modules.Sport.Codes.DLL --- End of inner exception stack trace ---

The problem occurs post-save on an item content. the content is 2 text boxes, one with name (string) and one with a reference (string). The two are set as props in a class (CodeInfo) and the controller class (CodeController) saves it through a SqlDataProvider to a SQL 2005 Server. Once all those bits and pieces are done it does a Redirect back to the content page (Response.Redirect(NavigateUrl(), true)) and shows the content list again. it is displaying the content just fine, however, above the module (there is only one module on the page) it displays the critical error above. The full code for the event handler after which the error occurs is:

/// <summary>
/// Handles the <see cref="LinkButton.Click"/> event for the <see cref="EditCode.Update"/>
/// <see cref="LinkButton"/>.
/// </summary>
/// <param name="sender">The <see cref="Object"/> source of the event.</param>
/// <param name="e">An <see cref="EventArgs"/> that contains event data.</param>
protected void Update_Click(object sender, EventArgs e)
{
   try
   
{
      
CodeInfo itemInfo = new CodeInfo();
      itemInfo
.Id = this._id;
      itemInfo
.Name = this.Name.Text;
      itemInfo
.Reference = this.Reference.Text;
      itemInfo
.CreatedByUser = this.UserId;
      
if (this._id == 0 || DotNetNuke.Common.Utilities.Null.IsNull(this._id))
         
CodeController.AddCode(itemInfo);
      
else
         
CodeController.UpdateCode(itemInfo);
      
// refresh cache
      
this.SynchronizeModule();
      
this.Response.Redirect(Globals.NavigateURL(), true);
   
}
   
catch (Exception ex)
   {
      
Exceptions.ProcessModuleLoadException(this, ex);
   }
}

The problem occurs whether adding a new code or updating an existing one, or even when you cancel (in the edit screen) or delete a code.

Here is the code for the cancel and delete handlers:

/// <summary>
/// Handles the <see cref="LinkButton.Click"/> event for the <see cref="EditCode.Cancel"/>
/// <see cref="LinkButton"/>.
/// </summary>
/// <param name="sender">The <see cref="Object"/> source of the event.</param>
/// <param name="e">An <see cref="EventArgs"/> that contains event data.</param>
protected void Cancel_Click(object sender, EventArgs e)
{
   
try
   
{
      
this.Response.Redirect(Globals.NavigateURL(), true);
   }
   
catch (Exception ex)
   {
      
Exceptions.ProcessModuleLoadException(this, ex);
   }
}

/// <summary>
/// Handles the <see cref="LinkButton.Click"/> event for the <see cref="EditCode.Delete"/>
/// <see cref="LinkButton"/>.
/// </summary>
/// <param name="sender">The <see cref="Object"/> source of the event.</param>
/// <param name="e">An <see cref="EventArgs"/> that contains event data.</param>
protected void Delete_Click(object sender, EventArgs e)
{
   
try
   
{
      
// only attempt delete if item exists
      
if (!DotNetNuke.Common.Utilities.Null.IsNull(this._id))
      {
         
CodeController.DeleteCode(this.ModuleId, this._id);
         
//refresh cache
         
this.SynchronizeModule();
         
this.Response.Redirect(Globals.NavigateURL(), true);
      }
   }
   
catch (Exception ex)
   {
      
Exceptions.ProcessModuleLoadException(this, ex);
   }
}

 

This is the view page normally (i'm logged in as 'host')

Thursday, September 28, 2006 ..:: Sports Admin ::.. SuperUser Account  Logout
TopPane

LeftPane

ContentPane

   
 
 Codes Minimize  
Visible By Administrators Only
  Reference Name
Edit [codref] [code name]

Add Content         

RightPane

BottomPane

 

Edit screen

Thursday, September 28, 2006 ..:: Sports Admin ::.. SuperUser Account  Logout
   
 
 Edit Code   
 

Update  Cancel  Delete 

Last Updated By SuperUser Account On 01/01/0001 00:00:00

  

After i click update, cancel or delete:

Thursday, September 28, 2006 ..:: Sports Admin ::.. SuperUser Account  Logout
TopPane

LeftPane

A critical error has occurred.
Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

ContentPane

   
 
 Codes Minimize  
Visible By Administrators Only
  Reference Name
Edit [codref] [code name]

Add Content         

RightPane

BottomPane

Has anyone seen this? Ideas, suggestions, comments?

Thanks in advance.

/b.

 

 
New Post
9/28/2006 3:08 AM
 
Anybody? No ideas at all?
 
New Post
10/4/2006 1:21 PM
 

I was having a similar problem.  Try changing your Response.Redirect to allow DotNetNuke to finish it's processing by:

 this.Response.Redirect(Globals.NavigateURL(), false);

If a control tries to end the current thread, which is what this.Response.Redirect(Globals.NavigateURL(), true); does, then that will cause the ThreadAbortException.

Aaron

 
New Post
10/4/2006 10:11 PM
 

Looks like that did the trick!

so it appears that doing the response.redirect(string, true) causes a threadabortexception which causes the securitypermission exception (how the two are related i don't exactly understand), so by using response.redirect(string, false) you don't abort the thread and therefore no securitypermission exception.

Thanks for the help arron.

Cheers,

/b

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0SecurityPermission Exception on NavigateUrl()SecurityPermission Exception on NavigateUrl()


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out