简体   繁体   English

无法从解决方案访问IIS Express文件夹

[英]Unable to reach IIS Express folder from solution

I'm trying to learn how to deserialize and serialize JSON, but the current directory which my web application outputs the json-file after serialization of my objects; 我正在尝试学习如何反序列化和序列化JSON,但是在对象序列化后,Web应用程序将输出json文件的当前目录。 is in the c:/user/ProgramFiles(x86)/IISExpress/-folder. 在c:/ user / ProgramFiles(x86)/ IISExpress /文件夹中。

I am unable to reach the json-file which I have manually moved to my App_Data-folder as it says “it cannot find file”. 我无法访问已手动移动到我的App_Data文件夹的json文件,因为它显示“找不到文件”。 It also gives me “Access to the path 'C:\\Program Files (x86)\\IIS Express\\Output.json' is denied.” For some reason. 它也给我“拒绝访问路径'C:\\ Program Files(x86)\\ IIS Express \\ Output.json'。”由于某种原因。

How would I go about solving the map-path as I have tried in my code to direct me to the right directory within the solution? 我将如何尝试解决代码问题,就像我在代码中尝试将我定向到解决方案中的正确目录一样?

Since you are trying to deserialize json from a file from App_Data, I believe you could put everything in a variable like this: 由于您尝试从App_Data的文件中反序列化json,因此我相信您可以将所有内容都放入这样的变量中:

string json = System.IO.File.ReadAllText(System.Web.Hosting.HostingEnvironment.MapPath(“/App_Data/Output.json”));

The reason it gives you the “Access to the path X is denied”, is because you are not running Visual Studio as an administrator. 之所以给您“拒绝访问路径X”的原因,是因为您没有以管理员身份运行Visual Studio。 Try right-clicking the VS-icon and click “Run as administrator”, and try again. 尝试右键单击VS图标,然后单击“以管理员身份运行”,然后重试。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法从Web应用程序访问IIS 6虚拟文件夹中的文件 - Unable To Access File In IIS 6 Virtual Folder From Web Application 无法在同一解决方案中使用IIS Express和2个独立项目进行跨域AJAX请求(从localhost:50675到localhost:27081) - Unable to make cross domain AJAX request (localhost:50675 to localhost:27081) using IIS Express with 2 separate projects in the same solution 为什么默认情况下将此文件保存到IIS Express文件夹? - Why is this file saved by default to the IIS Express folder? 如果可能,您可以从其解决方案/项目文件夹中托管一个.Net核心Web API并通过IIS进行调试 - If possible can you host a .Net core web API from it's solution/project folder and debug though IIS WebApi,文件存在但未找到文件,IIS始终从“ C:\\ Program Files(x86)\\ IIS Express”文件夹中读取 - WebApi, File exists but file not found, IIS always reads from “C:\Program Files (x86)\IIS Express” folder 如何使我的构建将内容从引用的库复制到IIS express文件夹? - How do I make my build copy content from a referenced library to IIS express folder? NLog.Config从IIS Express文件夹而不是Content Root读取 - NLog.Config read from IIS Express folder instead of Content Root 无法连接到 web 服务器“IIS Express” - Unable to connect to web server 'IIS Express' 无法将.net 3.5网站添加到IIS Express - Unable to Add .net 3.5 Website to IIS Express 如何使IIS Express在解决方案中运行所有网站? - How to make IIS Express run all websites in a solution?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM