SharePoint 个性化 url/重定向的最佳实践

2024-01-25

我的雇主使用 MOSS 2007 作为我们公司的 Intranet。它仅在安全 http 上运行,并且还通过 ISA 暴露给外界。我目前有一个请求,将转发 URL 添加到我们的网站,以便发生类似以下情况:

Intranet.mycompany.com/vanityname
重定向到-> Intranet.mycompany.com/somedeeplink/default.aspx

我完全预计随着时间的推移,这种事情会变得更受我们的用户欢迎。所以我正在寻找一种可扩展的解决方案。我读过各种有关使用转发元标记或转发 SharePoint 页面类型创建 /site/ 的文章。我还看到一些谈论直接在 IIS 中添加虚拟目录等。所有这些解决方案似乎都有些矫枉过正,并且不可避免地会占用网络服务器上更多的内存或处理时间。

我目前倾向于编写一个可以在 web.config 中配置并执行重定向的 http 模块。我想获得反馈,看看是否有其他人在 SharePoint 2007 中做过类似的事情并提出任何建议。同样,我希望实现一些无需稍后进行重大更改即可扩展的东西,并且将给我们的网络服务器带来最小的处理负担。谢谢!


我已经使用 HTTP 模块路由通过 MOSS 实现了 url 重定向。我在这里记录了我使用的代码以及哪些参数最适合我;

http://scaredpanda.com/2008/08/url-rewriting-with-sharepoint-moss-2007/ http://scaredpanda.com/2008/08/url-rewriting-with-sharepoint-moss-2007/罢工>

请看一下,如果这对您有帮助以及您是否有任何疑问,请告诉我。

Update:上面的链接不再有效,因此这里的文本来自我用于 URL 重定向的页面。

经过一番折腾后,我想出了一个好办法。当我在网上寻找示例时,很多人都说这是不可能的。但最终实施起来其实并没有花太多时间。这是我为完成这项工作而编写的 HttpModule。

关键部分是 this.app.BeginRequest += new EventHandler(app_BeginRequest) 位于请求前面并允许模块进行重定向。

和 HttpContext.Current.RewritePath(redirect, false);将向前推送必要的标头,以便接收 .aspx 页面将了解如何正确回发。

using System;
using System.Data;
using System.Data.SqlClient;
using System.Reflection;
using System.Collections;
using System.Text;
using System.Web;
using System.Web.Caching;
using System.Web.SessionState;
using System.Security.Cryptography;
using System.Configuration;
using System.Threading;
using System.IO;
using System.Security;
using System.Security.Principal;

namespace ScaredPanda
{
    public sealed class RewriteHttpModule : IHttpModule
    {
        HttpApplication app = null;
        ///
        /// Initializes the httpmodule
        ///
        public void Init(HttpApplication httpapp)
        {
            this.app = httpapp;
            this.app.BeginRequest += new EventHandler(app_BeginRequest);
        }

        public void app_BeginRequest(Object s, EventArgs e)
        {
            try
            {
        //determine if the income request is a url that we wish to rewrite.
        //in this case we are looking for an extension-less request
                string url = HttpContext.Current.Request.RawUrl.Trim();
                if (url != string.Empty
                    && url != "/"
                    && !url.EndsWith("/pages")
                    && !url.Contains(".aspx")
                    && url.IndexOf("/", 1) == -1)
                {
                    //this will build out the the new url that the user is redirected
                    //to ie pandas.aspx?pandaID=123
                    string redirect = ReturnRedirectUrl(url.Replace("/", ""));

            //if you do a HttpContext.Current.RewritePath without the 'false' parameter,
                    //the receiving sharepoint page will not handle post backs correctly
            //this is extremely useful in situations where users/admins will be doing a
                   //'site actions'  event
                   HttpContext.Current.RewritePath(redirect, false);
                }
            }
            catch (Exception ex)
            {
                //rubbish
            }
        }
    }
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

SharePoint 个性化 url/重定向的最佳实践 的相关文章

随机推荐

  • Drupal 7 hook_theme() 不加载模板文件

    我想得到一个very使用 drupal 的 hook theme 加载模板文件的简单模块 这几乎和你想象的一样简单 function sectionheader theme existing type theme path return a
  • 关于 Java lambda 相等和/或实例化[重复]

    这个问题在这里已经有答案了 为什么下面的代码片段在第二次通过时打印 true 不应该是一个新实例吗 import java util function Supplier public class Foo public static void
  • 如何在 OSX 上打开“共享菜单”首选项?

    与 Safari 非常相似 尝试实现一个按钮 单击该按钮会打开 系统偏好设置 gt 扩展 gt 共享菜单 窗格 我努力了 NSURL URL NSURL URLWithString x apple systempreferences com
  • Android:adb:权限被拒绝

    无论我输入什么adb shell它失败了Permission denied D android sdk windows platform tools gt adb shell find data name db find permissio
  • 连接 bash 中前 N 个参数之外的剩余参数

    我之前不需要编写任何 bash 脚本 这是我需要做的 我的脚本将使用一组字符串参数运行 刺数将超过 8 我将必须连接字符串 9 及之后的字符串 并从中生成一个字符串 像这样 myscript s1 s2 s3 s4 s5 s6 s7 s8
  • 当没有通过 Twisted TLSConnection 发送数据时 SSL 握手失败

    我开始考虑通过扩展当前的 Twisted FTP 来实现显式 FTP 大部分代码都很简单 实现 AUTH PBSZ PROT 很容易 我得到了一个有效的安全控制通道 我的问题是数据通道 客户端错误是 SSL routines SSL3 RE
  • 关于使用 AspectJ 执行策略

    我正在使用 Aspectj 来执行项目范围内的策略 我现在尝试实现的一件事是 除了使用 Guava 进行简单验证之外 任何 setter 方法中都不应该有任何逻辑Preconditions check 方法 public pointcut
  • $state,$stateParams,获取未定义的对象

    我从这两种方法中得到了意想不到的结果 我已经配置了 state stateProvider state status url status payment controller QuestCtrl templateUrl index htm
  • 使用 jQuery 切换图像

    有没有更好 更 jQuery 的方式来处理图像替换 var image obj children img if image attr src Images TreeCollapse gif image attr src Images Tre
  • 在 SQL Server 2008 中将 Varchar HH:MM 转换为整数分钟的查询

    我在 SQL Server 中有一个表 其中有一个列名TimeSpent Datatype Varchar 25 它基本上将时间存储为HH MM格式 根据现在的要求 我希望它能以分钟为单位给出实际花费的时间 即 01 00 给我 60 01
  • HttpServletRequest 的属性字段如何映射到原始 HTTP 请求?

    在 Java 中 可以使用 getAttribute 方法检索 HttpServletRequest 对象的属性字段 String myAttribute request getAttribute parameter name HttpSe
  • SQL中的count(1)是什么意思? [复制]

    这个问题在这里已经有答案了 select patientID count 1 from dbo nolock where admissiontime between 2020 01 31 and 2020 02 01 patientID i
  • 在 R 中保存数据文件

    我已成功将 txt 文件加载到 R 中 我想保存数据 以便我可以实际主动使用它 保存文件的命令是什么 我是否会将文件保存到现有包之一 UsingR MASS 或者只是作为一个单独的文件 您查找的命令是以下之一 save 将提到的对象保存为R
  • 在 Cocoa Touch 框架中包装静态库

    我有一个包含 2 个架构切片 armv7 arm64 的胖静态库 我正在尝试让它与 swift 一起工作并将其包装到 Cocoa Touch Framework 中 我做什么 创建Cocoa Touch框架项目 拖动带有标头的 a静态库 S
  • DataGridCell 空集 DbNull.value

    我正在用数据集填充数据网格并且I have my dataset verified for nullable values 我的问题是 当数据集验证时 它found 空行并且不显示错误 我想用 DBNull value 定义空单元格 有什么
  • 与 0xff 一起,需要澄清

    在下面的代码片段中 请考虑将第 8 行替换为带注释的等效项 1 private static String ipToText byte ip 2 StringBuffer result new StringBuffer 3 4 for in
  • Django NameError:名称“bPath”未定义

    我在 Django 1 7 上运行 当我运行 python manage py migrate 时出现以下错误 File home ymorin007 workspace sites jantiyes com src deeds migra
  • 如何忽略 perl grep 中的任何空值?

    我使用以下方法来计算文件中模式的出现次数 my lines grep text lt fp gt print lines 1 但有时它打印的值会比实际值多 1 我查了一下 这是因为最后一个元素 lines为空 也算在内 为什么有时 grep
  • Java中System.out.println()中的System、out、println是什么

    这个问题在这里已经有答案了 可能的重复 Java中System out println的含义是什么 https stackoverflow com questions 3406703 whats the meaning of system
  • SharePoint 个性化 url/重定向的最佳实践

    我的雇主使用 MOSS 2007 作为我们公司的 Intranet 它仅在安全 http 上运行 并且还通过 ISA 暴露给外界 我目前有一个请求 将转发 URL 添加到我们的网站 以便发生类似以下情况 Intranet mycompany