asp.net - 我的路径是虚拟的吗?

发布于 2024-08-03 07:38:50 字数 246 浏览 6 评论 0原文

是否有内置的 asp.net 方法来检查路径的“虚拟性”?

到目前为止,我能够做到这一点的唯一方法是使用以下 try 块:

public void Foo(String path){

    try
    {
        path = Server.MapPath(path);
    }
    catch(HttpException){}

    // do stuff with path
}

Is there a built-in asp.net method for checking the "virtualness" of a path?

The only way I've been able to do it so far is with the following try block:

public void Foo(String path){

    try
    {
        path = Server.MapPath(path);
    }
    catch(HttpException){}

    // do stuff with path
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤蝉 2024-08-10 07:38:50

Path.IsPathRooted 方法有效吗?

你得到的代码将是:

public void Foo(String path)
{
    if(!Path.IsPathRooted(path))
    {
        path = Server.MapPath(path);
    }

    // do stuff with path
}

Would the Path.IsPathRooted method work?

You're resulting code would be:

public void Foo(String path)
{
    if(!Path.IsPathRooted(path))
    {
        path = Server.MapPath(path);
    }

    // do stuff with path
}
冬天旳寂寞 2024-08-10 07:38:50

以下是您需要了解的有关 ASP.Net 路径的所有信息: Rick Strahl 的帖子“理解 ASP.Net Pahts”

Here is everything you need to know about ASP.Net paths: Rick Strahl's post "Making Sense of ASP.Net Pahts"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文