C#Web应用程序中的权限请求错误

编程入门 行业动态 更新时间:2024-10-26 07:40:01
本文介绍了C#Web应用程序中的权限请求错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试开发一个简单的Web应用程序,以从MetOffice服务加载xml文件,并使用其内容形成降雨地图的网址。当我尝试使用服务中的xml加载xml文档时,我收到了权限请求错误。我已经在桌面应用程序上做了更多这样的事情来做同样的事情并且从未出现过这个错误。我该如何解决?我正在写C#,谢谢。

I am trying to develop a simple web app to load an xml file from the MetOffice service and use its content to form a url to a rainfall map. I am getting the permission request error when I try to load the xml document with the xml from the service. I have done this and much more on a desktop application to do the same thing and have never had this error. How can I solve it? I am writing it C#, thank you.

private void save_Click(object sender, RoutedEventArgs e) { XmlDocument capabilities = new XmlDocument(); capabilities.Load("datapoint.metoffice.gov.uk/public/data/layer/wxobs/all/xml/capabilities?key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); TimeSteps.Items.Clear(); for (int x = 0; x < capabilities.SelectNodes("//Layer[@displayName='Rainfall']/Service/Times/Time").Count; x++) { TimeSteps.Items.Add(capabilities.SelectNodes("//Layer[@displayName='Rainfall']/Service/Times/Time")[x].InnerText); } { ImageLayer.Source = new BitmapImage(new Uri("datapoint.metoffice.gov.uk/public/data/layer/wxobs/RADAR_UK_Composite_Highres/png?TIME=" + TimeSteps.Items[0].ToString() + "Z&key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")); TimeSteps.SelectedIndex = 0; } }

错误:

Error:

SecurityException was unhandled in user code: Request for the permission of type 'System.Net.WebPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

推荐答案

出于测试目的,请在web.config中将您的信任级别设置为完全。如果此方法有效,请使用以下信息: msdn.microsoft/en -us / library / tkscy493(VS.80).aspx 以正确的方式配置信任级别。 For testing purposes, set your trust level to Full in the web.config. If this works, use this information: msdn.microsoft/en-us/library/tkscy493(VS.80).aspx to configure the trust level in the proper way.

更多推荐

C#Web应用程序中的权限请求错误

本文发布于:2023-10-17 10:56:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1500689.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   权限   错误   Web

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!