VB-ASP.NET2.0: Security Issue with Trust Level

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Steve Kiss
    New Member
    • Jun 2007
    • 19

    VB-ASP.NET2.0: Security Issue with Trust Level

    Hi. I have a fairly basic asp.net website that uses an Sql Server 2005 database and a custom provider to register users. I recently started testing the application in Medium Trust and I get the following error:

    System.Security .SecurityExcept ion: Request for the permission of type 'System.Securit y.Permissions.F ileIOPermission , mscorlib, Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b77a5c561934e08 9' failed.


    I don't understand where this error is coming from since I do absolutely NO FILEIO anywhere in my code. Furthermore, the stack trace reveals nothing. Has anyone experienced this before?
  • gomzi
    Contributor
    • Mar 2007
    • 304

    #2
    Originally posted by Steve Kiss
    Hi. I have a fairly basic asp.net website that uses an Sql Server 2005 database and a custom provider to register users. I recently started testing the application in Medium Trust and I get the following error:

    System.Security .SecurityExcept ion: Request for the permission of type 'System.Securit y.Permissions.F ileIOPermission , mscorlib, Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b77a5c561934e08 9' failed.


    I don't understand where this error is coming from since I do absolutely NO FILEIO anywhere in my code. Furthermore, the stack trace reveals nothing. Has anyone experienced this before?
    Yes. I too had experienced that error. Mine was because, I was trying to upload pictures and hadn't set the permissions properly.
    So, do you too upload pictures? If yes, then may be the error is at that place.
    Else, please post some more details (the code on the page where you get the error if possible).

    Regards,
    Gomzi.

    Comment

    • Steve Kiss
      New Member
      • Jun 2007
      • 19

      #3
      Originally posted by gomzi
      Yes. I too had experienced that error. Mine was because, I was trying to upload pictures and hadn't set the permissions properly.
      So, do you too upload pictures? If yes, then may be the error is at that place.
      Else, please post some more details (the code on the page where you get the error if possible).

      Regards,
      Gomzi.
      Hi.The problem seems to be generated by the login control in asp.net. I do no file io anywhere. The code that causes the problem is as follows:

      <asp:Login ID="Login1" runat="server" meta:resourceke y="LoginResourc e" MembershipProvi der="MyMembersh ipProvider" OnLoggedIn="goH ome" UserNameLabelTe xt="EmailAddres s:" DisplayRemember Me="false" EnableTheming=" false" UserNameRequire dErrorMessage=" Email Address is required." FailureAction=" RedirectToLogin Page">
      <LayoutTemplate >
      <table cellspacing="2" cellpadding="2" style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px">
      <tr>
      <td style="text-align: right">
      <span style="font-weight: bold">EMail&nbs p;Address:</span>
      </td>
      <td style="width: 100%">
      <asp:TextBox id="UserName" runat="server" Font-Names="Tahoma" width="224px" BorderStyle="So lid"
      BorderColor="#0 00000" BackColor="#e7e 9ed" />
      </td>
      </tr>
      <tr>
      <td style="text-align: right">
      <span style="font-weight: bold">Password: </span>
      </td>
      <td style="width: 100%">
      <asp:TextBox id="Password" runat="server" Font-Names="Tahoma" width="140px" TextMode="Passw ord"
      MaxLength="12" BorderStyle="So lid" BorderColor="#0 00000" BackColor="#e7e 9ed" />
      </td>
      </tr>
      <tr>
      <td>
      </td>
      <td colspan="2">
      <asp:Label id="LoginResult " runat="server" CssClass="Error Message" Visible="false" />
      <asp:RequiredFi eldValidator id="EmailValida tor" runat="server" Display="Dynami c" ControlToValida te="UserName"
      ErrorMessage="Y ou must supply a valid E-Mail Address in order to log in!" ValidationGroup ="LoginValidati on"/>
      <asp:Label id="NastyLoginW orkaround" runat="server" Visible="True" Text="<br />" />
      <asp:requiredfi eldvalidator id="PasswordReq uired" runat="server" Display="Dynami c" ErrorMessage="Y ou must supply a Password in order to log in!" ControlToValida te="Password" ValidationGroup ="LoginValidati on" />
      <br />

      </td>
      </tr>
      <tr>
      <td colspan="2">
      <asp:Button id="Submit" runat="server" Text="Login" CommandName="Lo gin" ValidationGroup ="LoginValidati on" />&nbsp;&nbsp;&n bsp;
      <a href="Register. aspx">Register</a>
      &nbsp;&nbsp;&nb sp;
      </td>
      </tr>
      <tr>
      <td colspan="2">
      <a href="PasswordR ecovery.aspx">F orgot Password</a>
      </td>
      </tr>
      </table>
      </LayoutTemplate>
      </asp:Login>

      Comment

      • gomzi
        Contributor
        • Mar 2007
        • 304

        #4
        Originally posted by Steve Kiss
        Hi.The problem seems to be generated by the login control in asp.net. I do no file io anywhere. The code that causes the problem is as follows:

        <asp:Login ID="Login1" runat="server" meta:resourceke y="LoginResourc e" MembershipProvi der="MyMembersh ipProvider" OnLoggedIn="goH ome" UserNameLabelTe xt="EmailAddres s:" DisplayRemember Me="false" EnableTheming=" false" UserNameRequire dErrorMessage=" Email Address is required." FailureAction=" RedirectToLogin Page">
        <LayoutTemplate >
        <table cellspacing="2" cellpadding="2" style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px">
        <tr>
        <td style="text-align: right">
        <span style="font-weight: bold">EMail&nbs p;Address:</span>
        </td>
        <td style="width: 100%">
        <asp:TextBox id="UserName" runat="server" Font-Names="Tahoma" width="224px" BorderStyle="So lid"
        BorderColor="#0 00000" BackColor="#e7e 9ed" />
        </td>
        </tr>
        <tr>
        <td style="text-align: right">
        <span style="font-weight: bold">Password: </span>
        </td>
        <td style="width: 100%">
        <asp:TextBox id="Password" runat="server" Font-Names="Tahoma" width="140px" TextMode="Passw ord"
        MaxLength="12" BorderStyle="So lid" BorderColor="#0 00000" BackColor="#e7e 9ed" />
        </td>
        </tr>
        <tr>
        <td>
        </td>
        <td colspan="2">
        <asp:Label id="LoginResult " runat="server" CssClass="Error Message" Visible="false" />
        <asp:RequiredFi eldValidator id="EmailValida tor" runat="server" Display="Dynami c" ControlToValida te="UserName"
        ErrorMessage="Y ou must supply a valid E-Mail Address in order to log in!" ValidationGroup ="LoginValidati on"/>
        <asp:Label id="NastyLoginW orkaround" runat="server" Visible="True" Text="<br />" />
        <asp:requiredfi eldvalidator id="PasswordReq uired" runat="server" Display="Dynami c" ErrorMessage="Y ou must supply a Password in order to log in!" ControlToValida te="Password" ValidationGroup ="LoginValidati on" />
        <br />

        </td>
        </tr>
        <tr>
        <td colspan="2">
        <asp:Button id="Submit" runat="server" Text="Login" CommandName="Lo gin" ValidationGroup ="LoginValidati on" />&nbsp;&nbsp;&n bsp;
        <a href="Register. aspx">Register</a>
        &nbsp;&nbsp;&nb sp;
        </td>
        </tr>
        <tr>
        <td colspan="2">
        <a href="PasswordR ecovery.aspx">F orgot Password</a>
        </td>
        </tr>
        </table>
        </LayoutTemplate>
        </asp:Login>
        Well, I now remember adding this ->
        <identity impersonate="tr ue" userName="" password=""/>
        in web.config.
        Try adding that and see mate.

        Comment

        • Steve Kiss
          New Member
          • Jun 2007
          • 19

          #5
          I tried you suggestion Gomzi but no cigar. Thanks anyways.

          Comment

          Working...