System.Security.SecurityException: Error de solicitud de permiso de tipo System.Net.WebPermission, S

Discussion in 'ASP .Net' started by Luis Esteban Valencia, Jul 14, 2005.

  1. Hello I have this error when I submit the page with the following code. I
    had never see this kind of errors.

    Thanks

    private void btnsubmit_Click(object sender, System.EventArgs e)

    {

    string requestLocation = "http://estacion15/HTTPSender/BTSHTTPReceive.dll";

    Status.Text = "";

    XmlDocument xmlDocument = new XmlDocument();

    xmlDocument.PreserveWhitespace = true;

    XmlNode tempXmlNode = xmlDocument.CreateNode(XmlNodeType.Element,
    "Activity", "http://que.activity");

    xmlDocument.AppendChild(tempXmlNode);

    tempXmlNode = xmlDocument.CreateNode(XmlNodeType.Attribute, "type", "");

    tempXmlNode.Value = type.SelectedItem.Text;

    xmlDocument.DocumentElement.Attributes.Append( (XmlAttribute)tempXmlNode);

    tempXmlNode = xmlDocument.CreateNode(XmlNodeType.Element, "Location", "");

    tempXmlNode.InnerText = location.Text;

    xmlDocument.DocumentElement.AppendChild(tempXmlNode);

    tempXmlNode = xmlDocument.CreateNode(XmlNodeType.Element, "Timestamp", "");

    DateTime now = DateTime.Now;

    tempXmlNode.InnerText = now.ToString("s");

    xmlDocument.DocumentElement.AppendChild(tempXmlNode);

    tempXmlNode = xmlDocument.CreateNode(XmlNodeType.Element, "Notes", "");

    tempXmlNode.InnerText = notes.Text;

    xmlDocument.DocumentElement.AppendChild(tempXmlNode);

    try

    {

    HttpWebRequest request = (HttpWebRequest)
    HttpWebRequest.Create(requestLocation);

    request.Method = "POST";

    ASCIIEncoding encoding = new ASCIIEncoding();

    byte[] requestData = encoding.GetBytes(xmlDocument.OuterXml);

    request.ContentType="application/x-www-form-urlencoded";

    request.ContentLength = xmlDocument.OuterXml.Length;

    Status.Text += "Submitting activity message";

    Stream requestStream = request.GetRequestStream();

    requestStream.Write(requestData,0,requestData.Length);

    requestStream.Flush();

    requestStream.Close();

    HttpWebResponse response = (HttpWebResponse) request.GetResponse();

    StreamReader responseData = new StreamReader( response.GetResponseStream());

    Status.Text = System.Web.HttpUtility.HtmlEncode( responseData.ReadToEnd()) +
    "<br>";

    }

    catch (WebException wex)

    {

    Status.Text = "Unable to complete web request. Web Exception error: " +
    wex.Message;

    }

    }



    }



    Error de servidor en la aplicación '/HTTPSender'.
    ----------------------------------------------------------------------------
    ----

    Excepción de seguridad
    Descripción: La aplicación intentó realizar una operación no permitida por
    la directiva de seguridad. Para otorgar a esta aplicación los permisos
    necesarios, póngase en contacto con el administrador del sistema o cambie el
    nivel de confianza de la aplicación en el archivo de configuración.

    Detalles de la excepción: System.Security.SecurityException: Error de
    solicitud de permiso de tipo System.Net.WebPermission, System,
    Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.

    Error de código fuente:

    [Líneas de código fuente no relevantes]

    Archivo de origen: webform1.aspx.cs Línea: 84

    Seguimiento de la pila:

    [SecurityException: Error de solicitud de permiso de tipo
    System.Net.WebPermission, System, Version=1.0.5000.0, Culture=neutral,
    PublicKeyToken=b77a5c561934e089.]
    System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet
    grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
    PermissionToken permToken) +666
    System.Security.CodeAccessSecurityEngine.Check(PermissionToken permToken,
    CodeAccessPermission demand, StackCrawlMark& stackMark, Int32 checkFrames,
    Int32 unrestrictedOverride) +0
    System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap,
    StackCrawlMark& stackMark) +88
    System.Security.CodeAccessPermission.Demand() +62
    System.Net.HttpRequestCreator.Create(Uri Uri)
    System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase)
    System.Net.WebRequest.Create(String requestUriString)
    HTTPSender.WebForm1.btnsubmit_Click(Object sender, EventArgs e) in
    webform1.aspx.cs:84
    System.Web.UI.WebControls.Button.OnClick(EventArgs e)

    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
    stBackEvent(String eventArgument)
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
    sourceControl, String eventArgument)
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
    System.Web.UI.Page.ProcessRequestMain()
    System.Web.UI.Page.ProcessRequest()
    System.Web.UI.Page.ProcessRequest(HttpContext context)

    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionSte
    p.Execute()
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
    completedSynchronously) +87



    ----------------------------------------------------------------------------
    ----
    Información de versión: Versión de Microsoft .NET Framework:1.1.4322.985;
    Versión de ASP.NET:1.1.4322.968
     
    Luis Esteban Valencia, Jul 14, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    9,298
    bruce barker \(sqlwork.com\)
    Aug 14, 2006
  2. Siberwulf
    Replies:
    0
    Views:
    1,636
    Siberwulf
    Oct 6, 2006
  3. kb
    Replies:
    0
    Views:
    485
  4. Leyla
    Replies:
    2
    Views:
    697
    Leyla
    Aug 17, 2006
  5. SD

    [WSS003] System.Net.WebPermission pb

    SD, Sep 14, 2006, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    110
Loading...

Share This Page