将 ASP.Net 3.5 SP1 路由与 SharePoint 2007 结合使用

发布于 2024-07-06 03:28:25 字数 209 浏览 5 评论 0原文

我正在尝试在 SharePoint 网站上设置一些友好的 URL。 我知道我可以使用 RewritePath 实现 ASP.Net 2.0 友好 URL,但我想知道是否可以使用 ASP.NET 3.5 SP1 附带的 System.Web.Routing。

我想我已经弄清楚如何加载路由表,但我不清楚使用什么方法来传递正确的 IHttpHandler。

谢谢!

I'm trying to setup some friendly URLs on a SharePoint website. I know that I can do the ASP.Net 2.0 friendly URLs using RewritePath, but I was wondering if it was possible to make use of the System.Web.Routing that comes with ASP.NET 3.5 SP1.

I think I've figured out how to get my route table loaded, but I'm not clear on what method to use to get the correct IHttpHandler to pass out.

Thanks!

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

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

发布评论

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

评论(3

萝莉病 2024-07-13 03:28:25

我被要求将此视为 Share Point 评估流程的一部分。

我的理解是,uri 模板本质上是主机名,后跟递归文件夹结构。

Share Point 将 uri 截断为 255 个字符,这使情况变得更加复杂。 因此,如果您有特别深或冗长的文件夹结构,那么您的 uri 可能会变得无效。

我正在考虑通过遵循人类可读的约定并转换为共享点约定来美化/整理 uri。 即:

http://myhostname.com/ docs/ human-resources/case-files/2009/reviews/ed-blackburn.docx

转换为共享点:

http://myhostname.com/ human%20resources/case%20files/2009/reviews/ed%20blackburn.docx

任何其他所需服务都可以由控制器控制。

如果长度超过 255 个字符,我最初建议使用某种tinyurl 方法。

I've been asked to look at this as part of an Share Point evaluation process.

My understanding is that the uri template is essentially host name followed by the recursive folder structure.

This is further complicated by Share Point truncating the uri at 255 characters. So if you have a particularly deep or verbose folder structure then your uri can become invalid.

I was thinking about essentially prettifying / tidying up the uri by follow a human readable convention and convert to the Share Point convention. i.e:

http://myhostname.com/docs/human-resources/case-files/2009/reviews/ed-blackburn.docx

converts to Share Points:

http://myhostname.com/human%20resources/case%20files/2009/reviews/ed%20blackburn.docx

Any additional required services can be controlled by the controller.

If longer than 255 characters some kind of tinyurl approach would be my initial suggestion.

极度宠爱 2024-07-13 03:28:25

我最终选择了 Ryan 拥有的:

var route = new Route("blah/{*path}", new MyRouteHandler());
RouteTable.Routes.Add(route);
public class MyRouteHandler : IRouteHandler
{    
public IHttpHandler GetHttpHandler(RequestContext requestContext)    
{        
     //rewrite to some know sharepoint path
     HttpContext.Current.RewritePath("~/Pages/Default.aspx");

     // return some HTTP handler here  
     return new DefaultHttpHandler();  

}}

这对我来说似乎没问题。

I ended up taking what Ryan had:

var route = new Route("blah/{*path}", new MyRouteHandler());
RouteTable.Routes.Add(route);
public class MyRouteHandler : IRouteHandler
{    
public IHttpHandler GetHttpHandler(RequestContext requestContext)    
{        
     //rewrite to some know sharepoint path
     HttpContext.Current.RewritePath("~/Pages/Default.aspx");

     // return some HTTP handler here  
     return new DefaultHttpHandler();  

}}

That seems to work ok for me.

慢慢从新开始 2024-07-13 03:28:25

它应该像下面一样简单。

var route = new Route("blah/{*path}", new MyRouteHandler());
RouteTable.Routes.Add(route);

public class MyRouteHandler : IRouteHandler
{
    public IHttpHandler GetHttpHandler(RequestContext requestContext)
    {
        // return some HTTP handler here
    }
}

然后在 web.config 中的 HTTP 模块下注册 System.Web.Routing.UrlRoutingModule 就可以了。

<add name="Routing" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

It should be as easy as the below.

var route = new Route("blah/{*path}", new MyRouteHandler());
RouteTable.Routes.Add(route);

public class MyRouteHandler : IRouteHandler
{
    public IHttpHandler GetHttpHandler(RequestContext requestContext)
    {
        // return some HTTP handler here
    }
}

Then register System.Web.Routing.UrlRoutingModule under HTTP modules in web.config and you should be good to go.

<add name="Routing" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文