enable feature AJAX of MOSS2007
As default, the feature AJAX of MOSS2007 is disabled, so the site web configuration file should be modified to enable AJAX to achieve the auto complete functionality. The following are steps how to enable it.
Option 1: Modify it manually
step1: Open the web.config file, find out the <configSections> section then fill content out in the section below:
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</sectionGroup>
</sectionGroup>
</sectionGroup>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
Step2:Find the <pages> section then add the declaration of control below
<controls>
<add tagPrefix="asp" tagName="" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35" />
</controls>
Step3:Add the declaration of the assembly inside <assemblies> section
<add assembly="System.Web.Extensions, Version=3.5.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
Step4: Add predicate handler in the <httphandlers> section:
<add path="*.asmx" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory,System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
<add path="*.AppService.axd" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
<add path="ScriptSource.axd" verb="GET,HEAD" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
Step5: Add script module inside the <httpModules> section as below:
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
Step6:Add logging configuration inside <configuration> section:
<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
<listeners>
<add name="Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
fileName="C:\trace.log" traceOutputOptions="DateTime" />
</listeners>
<formatters>
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
template="Timestamp: {timestamp}{newline} Message: {message}{newline} Category: {category}{newline} Priority:
{priority}{newline} EventId: {eventid}{newline} Severity: {severity}{newline} Title:{title}{newline} Machine:
{localMachine}{newline} App Domain: {localAppDomain}{newline} ProcessId: {localProcessId}{newline} Process Name:
{localProcessName}{newline} Thread Name: {threadName}{newline} Win32 ThreadId:{win32ThreadId}{newline} Extended Properties:
{dictionary({key} - {value}{newline})}" name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="All" name="General">
<listeners>
<add name="Flat File Trace Listener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="Flat File Trace Listener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>
Option 2: Modify it automaticall by Feature
public class WebConfigModification
{
private SPSite _site = null;
public WebConfigModification(SPSite site)
{
this._site = site;
}
/// <summary>
/// open the web.config file, find out the configSections section then fill in the section
/// </summary>
private void ModifyConfigSections(Configuration config)
{
try
{
ConfigurationSectionGroup sectionGroup = config.GetSectionGroup("system.web.extensions");
if (sectionGroup == null)
{
SystemWebExtensionsSectionGroup topGroup = new SystemWebExtensionsSectionGroup();
config.SectionGroups.Add("system.web.extensions", topGroup); ScriptingSectionGroup scriptingGroup = new ScriptingSectionGroup();
topGroup.SectionGroups.Add("scripting", scriptingGroup); ScriptingScriptResourceHandlerSection scriptResourceHandler = new ScriptingScriptResourceHandlerSection();
scriptingGroup.Sections.Add("scriptResourceHandler", scriptResourceHandler); ScriptingWebServicesSectionGroup webServiceGroup = new ScriptingWebServicesSectionGroup();
scriptingGroup.SectionGroups.Add("webServices", webServiceGroup); ScriptingJsonSerializationSection jsonSerialization = new ScriptingJsonSerializationSection();
webServiceGroup.Sections.Add("jsonSerialization", jsonSerialization); ScriptingProfileServiceSection profileService = new ScriptingProfileServiceSection();
webServiceGroup.Sections.Add("profileService", profileService); ScriptingAuthenticationServiceSection authenticationService = new ScriptingAuthenticationServiceSection();
webServiceGroup.Sections.Add("authenticationService", authenticationService);
config.Save();
}
}
catch (Exception ex)
{
throw new Exception("ModifyConfigSectons error :" + ex.Message);
}
} /// <summary>
/// find the pages section then add the declaration of control
/// </summary>
private void ModifyPagesSection(Configuration config)
{
try
{
bool prefixExists = false;
PagesSection pagesSection = (PagesSection)config.GetSection(@"system.web/pages");
for (int i = ; i < pagesSection.Controls.Count; i++)
{
TagPrefixInfo prefix = pagesSection.Controls[i];
if (prefix.TagPrefix.ToLower().Trim() == "asp" && prefix.Namespace.ToLower().Trim() == "system.web.ui")
{
prefixExists = true;
break;
}
}
if (!prefixExists)
{
TagPrefixInfo prefixInfo = new TagPrefixInfo("asp", "System.Web.UI", "System.Web.Extensions, Version=3.5.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35", "", "");
pagesSection.Controls.Add(prefixInfo);
config.Save();
}
}
catch (Exception ex)
{
throw new Exception("MOdifyPagesSection error: " + ex.Message);
}
} /// <summary>
/// add the declaration of the assembly inside assemblies section
/// </summary>
private void ModifyAssemblies(Configuration config)
{
try
{
bool assemblyexists = false;
CompilationSection compilationSection = (CompilationSection)config.GetSection(@"system.web/compilation");
AssemblyInfo newAssembly = new AssemblyInfo("System.Web.Extensions, Version=3.5.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35");
for (int i = ; i < compilationSection.Assemblies.Count; i++)
{
AssemblyInfo assembly = compilationSection.Assemblies[i];
if (assembly.Equals(newAssembly))
{
assemblyexists = true;
break;
}
}
if (!assemblyexists)
{
compilationSection.Assemblies.Add(newAssembly);
config.Save();
}
}
catch (Exception ex)
{
throw new Exception("ModifyAssemblies error: " + ex.Message);
}
} /// <summary>
/// add the declaration of the assembly inside assemblies section
/// </summary>
private void ModifyHttpHandlers(Configuration config)
{
try
{
List<HttpHandlerAction> handlers = new List<HttpHandlerAction>();
HttpHandlersSection handlersSection = (HttpHandlersSection)config.GetSection(@"system.web/httpHandlers");
HttpHandlerAction asmxHandlerAction = new HttpHandlerAction("*.asmx", "System.Web.Script.Services.ScriptHandlerFactory,System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", "*", false);
handlers.Add(asmxHandlerAction); HttpHandlerAction appServiceHandlerAction = new HttpHandlerAction("*.AppService.axd", "System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", "*", false);
handlers.Add(appServiceHandlerAction); HttpHandlerAction getHeadHandlerAction = new HttpHandlerAction("ScriptSource.axd", "System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", "GET,HEAD", false);
handlers.Add(getHeadHandlerAction); bool handlerActionExists = false;
foreach (HttpHandlerAction handlerAction in handlers)
{
for (int i = ; i < handlersSection.Handlers.Count; i++)
{
if (handlersSection.Handlers[i].Equals(handlerAction))
{
handlerActionExists = true;
}
}
if (!handlerActionExists)
{
handlersSection.Handlers.Add(handlerAction);
config.Save();
} }
}
catch (Exception ex)
{
throw new Exception("ModifyHttpHandlers error: " + ex.Message);
}
} /// <summary>
/// add script module inside the httpModules section
/// </summary>
private void ModifyModules(Configuration config)
{
try
{
HttpModulesSection modulesSection = (HttpModulesSection)config.GetSection("system.web/httpModules");
HttpModuleAction moduleAction = new HttpModuleAction("ScriptModule", "System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); bool moduleExists = false;
for (int i = ; i < modulesSection.Modules.Count; i++)
{
if (modulesSection.Modules[i].Name.ToLower().Trim() == moduleAction.Name.ToLower().Trim())
{
moduleExists = true;
}
}
if (!moduleExists)
{
modulesSection.Modules.Add(moduleAction);
config.Save();
} }
catch (Exception ex)
{
throw new Exception("MOdifyModules error: " + ex.Message); } } /// <summary>
/// add safecontrol to the web.config
/// </summary>
/// <param name="site"></param>
private void RegisterSafeControl()
{
try
{
if (_site != null)
{
SPSecurity.RunWithElevatedPrivileges(() =>
{
SPWebApplication webApp = _site.WebApplication; // Create a modification
SPWebConfigModification mod = new SPWebConfigModification(
"SafeControl[@Assembly=\"System.Web.Extensions, Version=3.5.0.0, Culture=neutral,PublicKeyToken=31bf3856ad364e35\"][@Namespace=\"System.Web.UI\"]"
+ "[@TypeName=\"*\"][@Safe=\"True\"][@AllowRemoteDesigner=\"True\"]"
, "/configuration/SharePoint/SafeControls"
);
mod.Owner = "PeopleSearch";
mod.Sequence = ;
mod.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
mod.Value = "<SafeControl Assembly='System.Web.Extensions, Version=3.5.0.0, Culture=neutral,PublicKeyToken=31bf3856ad364e35' Namespace='System.Web.UI' TypeName='*' Safe='True' />"; // Add the modification to the collection of modifications //bool exists = false;
//foreach (SPWebConfigModification modificartion in webApp.WebConfigModifications)
//{
// if (modificartion.Name == mod.Name)
// {
// exists = true;
// break;
// }
//}
//if (!exists)
{ webApp.WebConfigModifications.Add(mod);
webApp.Update();
// Apply the modification
webApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();
}
});
}
}
catch (Exception ex)
{
throw new Exception("Register SafeControl error: " + ex.Message);
}
} /// <summary>
/// modify all
/// </summary>
/// <param name="config"></param>
public void ModifiedToEnableAJAX(Configuration config)
{
if (config == null)
{
return;
}
ModifyModules(config);
ModifyPagesSection(config);
ModifyHttpHandlers(config);
ModifyConfigSections(config);
ModifyAssemblies(config);
//RegisterSafeControl();
} public void RemoveSafeControl()
{
try
{
if (_site != null)
{
SPSecurity.RunWithElevatedPrivileges(() =>
{
SPWebApplication webApp = _site.WebApplication;
Collection<SPWebConfigModification> modsCollection = webApp.WebConfigModifications;
SPWebConfigModification configModFound = null;
// Find the most recent modification of a specified owner
int modsCount1 = modsCollection.Count;
for (int i = modsCount1 - ; i > -; i--)
{
if (modsCollection[i].Owner == "PeopleSearch")
{
configModFound = modsCollection[i];
}
} // Remove it and save the change to the configuration database
modsCollection.Remove(configModFound);
webApp.Update(); // Reapply all the configuration modifications
webApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications(); });
}
}
catch (Exception ex)
{
throw new Exception("Remove SafeControl error: " + ex.Message);
}
}
}
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPSite site = null; try
{
// Get a reference to the Site Collection of the feature
if (properties.Feature.Parent is SPSite)
{ site = properties.Feature.Parent as SPSite; } if (site != null)
{
string path = site.WebApplication.IisSettings[SPUrlZone.Default].Path.ToString();
BackUpConfiguration(path); Configuration config = WebConfigurationManager.OpenWebConfiguration("/"); string logConfigPath = string.Empty;
var obj = config.AppSettings.Settings["logConfigPath"];
if (null != obj)
{
logConfigPath = obj.ToString();
}
ConfigLogSettings(path, logConfigPath);
//config.SaveAs(Path.Combine(path, fileName), ConfigurationSaveMode.Minimal, true); WebConfigModification modification = new WebConfigModification(site);
modification.ModifiedToEnableAJAX(WebConfigurationManager.OpenWebConfiguration("/"));
}
}
catch (Exception ex)
{
TraceLog.Error(ex.Message);
}
}
}
enable feature AJAX of MOSS2007的更多相关文章
- ajax cache enable and ajax concurrency!
		Today, forget to close ajax cache which leads to duplicate result from cache as to Jquery, this way, ... 
- 怎样用命令行管理SharePoint Feature?
		普通情况下对IT管理者来说.在SharePoint Farm中维护Feature,更喜欢使用命令行实现,这样能够省去登录到详细网站的操作. 比方IT接到end user的一个需求,要开启Site Co ... 
- IP-reputation feature
		IP-reputation feature https://blog.norz.at/citrix-netscaler-ip-reputation-feature/ I recently had to ... 
- A javascript library providing cross-browser, cross-site messaging/method invocation. http://easyxdm.net
		easyXDM - easy Cross-Domain Messaging easyXDM is a Javascript library that enables you as a develope ... 
- How To Configure NetScaler AppFlow for SolarWinds
		How To Configure NetScaler AppFlow for SolarWinds 来源 https://support.citrix.com/article/CTX227300 A ... 
- 使用Ztree新增角色和编辑角色回显
		最近在项目中使用到了ztree,在回显时候费了点时间,特记录下来供下次参考. 1.新增角色使用ztree加载权限,由于权限不多,所以使用直接全部加载. 效果图: 具体涉及ztree代码: jsp中导入 ... 
- MPS添加管理设备实例NS的过程
		MPS添加管理设备实例NS的过程 MPS添加实例NS设备节点: > show snmp community Done > > add snmp community public al ... 
- MPSVPX 配置
		MPSVPX 配置 设置主机名,IP地址,掩码,网关,DNS服务器,时区(使用WebGUI界面设置). bash-2.05b# cat svm.conf arp -d -a route flush i ... 
- Autotools Mythbuster
		Preface Diego Elio "Flameeyes" Pettenò Author and Publisher <flameeyes@flameeyes.eu> ... 
随机推荐
- weboffice控件使用不能嵌入网页
			var s = ""s += "<object id=WebOffice1 height=586 width='100%' style='LEFT: 0px; TO ... 
- Android的学习第六章(布局一TableLayout)
			今天我们来简单的说一下Android不居中的TableLayout布局(表格布局) 表格布局的意思就是将我们的布局看做为一个表格,主要用于对控件进行整齐排列 我们看一个简单的案例 <TableL ... 
- MYSQL中存储过程的创建,调用及语法
			MySQL 存储过程是从 MySQL 5.0 开始增加的新功能.存储过程的优点有一箩筐.不过最主要的还是执行效率和SQL 代码封装.特别是 SQL 代码封装功能,如果没有存储过程,在外部程序访问数据库 ... 
- zigbee学习之路(十一):看门狗
			一.前言 今天,我们要通过实验学习和认识一下看门狗的使用,看门狗是为了防止防止程序跑飞的,通过不断的喂狗,使看门狗能持续监管程序的运行状态,当程序跑飞时,能及时把程序拽回来. 二.原理与分析 在CPU ... 
- table表格在设置文字垂直居中后,在表格显示相同排列的数据(比如:testtesttesttsttesttesstestse很多的test)时此表格不能换行
			table设置了垂直居中后在表格显示相同排列的数据(比如:testtesttesttsttesttesstestse很多的test)时此表格不能换行, 此时会导致table会把页面撑的很宽,导致表格后 ... 
- (转载)The One Sign You Will Be Rich-(by Brian de Haaff Founder and CEO Aha! -- world's #1 product roadmap software)
			When I was studying Philosophy at Berkeley, a friend told me that she could tell who was going to be ... 
- 【前端】screenX/Y, clientX/Y, pageX/Y 的区别
			一图胜千言. 做了一个图: 
- 【前端】stopPropagation, preventDefault, return false的区别
			e.stopPropagation()阻止事件冒泡或者捕获 因为事件可以在各层级的节点中传递, 不管是冒泡还是捕获, 有时我们希望事件在特定节点执行完之后不再传递, 可以使用事件对象的 stopPro ... 
- 怎样处理“error C2220: warning treated as error - no object file generated”错误
			最近用VS2010 编译ceflib开源库是出现"怎样处理"error C2220: warning treated as error - no object file gener ... 
- Unity手撸2048小游戏——背景文字控制
			今天继续昨天的计划吧 1.新建项目.场景命名啥的都不说了吧. 2.直接开始新建一个Image,顺便把Image改名成Chessman 3.选中Image新建一个Text对象,调整下大小位置.这样就算完 ... 
