c# - 获取 Application_Start 中的当前应用程序物理路径

标签 c# asp.net

我无法使用

获取 Application_Start 中的当前物理路径
HttpContext.Current.Request.PhysicalApplicationPath

因为当时没有Request对象。

我还能如何获得物理路径?

最佳答案

 protected void Application_Start(object sender, EventArgs e)
 {
     string path = Server.MapPath("/");
     //or 
     string path2 = Server.MapPath("~");
     //depends on your application needs

 }

关于c# - 获取 Application_Start 中的当前应用程序物理路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1495504/

相关文章:

c# - asp.net: (c# client-side) 如何访问页面加载后创建的 html 元素?

javascript - 如何将选择列表选项发布到 MVC 操作方法?

c# - WPF - 使用 DataTemplate 时通过键入选择 ComboBox 值

javascript - 如何在从代码隐藏显示之前在弹出窗口中选择预填充的下拉列表选项

c# - String.Format 没有正确转换阿拉伯语的整数

c# - 如何让我的 MultiSelectList 绑定(bind)到我的数据模型?

javascript - 当前上下文中不存在文本框

asp.net - 如何从 ASP.NET Core 项目中删除 docker 支持?

c# - 将 .NET Core Identity 与 API 结合使用

c# - 从 azure blob 存储下载 zip 后无法访问该 zip