May 31, 2011, 6:44 AM
[FIXED] [RC2] Solution for web.config check-out problem in Web Application under source control (Team Foundation Server (TFS))
Dear all,
There is a problem in v1.0c with web.config file in a Web Application project under Team Foundation Server source control. This file automatically checks out and causes problems for teams of developers.
--------------------------
Solution
I found out that there is a bug in Ext.net source code that tries to open web.config read-write to add missing parts automatically.
To solve the problem, I changed two parts of the source code to open web.config read-only:
Therefore, we should use:
1- Ext.Net\Utility\WebConfigUtils.cs
2- Ext.Net\Core\ResourceHandler.cs
It's nice if you could submit these changes to your newer version of Coolite. Thank you for your time and consideration.
Best
There is a problem in v1.0c with web.config file in a Web Application project under Team Foundation Server source control. This file automatically checks out and causes problems for teams of developers.
--------------------------
Solution
I found out that there is a bug in Ext.net source code that tries to open web.config read-write to add missing parts automatically.
To solve the problem, I changed two parts of the source code to open web.config read-only:
Therefore, we should use:
app.OpenWebConfiguration(true); // opens web.config in read-only mode
instead of app.OpenWebConfiguration(false); // opens web.config in read-write mode, so causes auto check-out under source control like TFS
In this case two files should be edited like this: ( I don't know why I can't attach cs files here, so it put the code here.)1- Ext.Net\Utility\WebConfigUtils.cs
// changed by mohghaderi 02 May 2011
internal static void CheckConfiguration(ISite site)
{
if (site == null)
{
return;
}
IWebApplication app = (IWebApplication)site.GetService(typeof(IWebApplication));
if (app == null)
{
return;
}
if (!IsChangeRequiredToWebConfig(app))
{
return;
}
Configuration config = app.OpenWebConfiguration(false);
HttpHandlersSection handlers = (HttpHandlersSection)config.GetSection("system.web/httpHandlers");
// Does the httpHandlers Secton already exist?
if (handlers == null)
{
// If not, add it...
handlers = new HttpHandlersSection();
ConfigurationSectionGroup group = config.GetSectionGroup("system.web");
// Does the system.web Section already exist?
if (group == null)
{
// If not, add it...
config.SectionGroups.Add("system.web", new ConfigurationSectionGroup());
group = config.GetSectionGroup("system.web");
}
if (group != null)
{
group.Sections.Add("httpHandlers", handlers);
}
}
HttpHandlerAction action = new HttpHandlerAction("*/ext.axd", "Ext.Net.ResourceHandler", "*", false);
// Does the ResourceHandler already exist?
if (handlers.Handlers.IndexOf(action) < 0)
{
// If not, add it...
handlers.Handlers.Add(action);
config.Save();
}
HttpModulesSection modules = (HttpModulesSection)config.GetSection("system.web/httpModules");
// Does the httpModules Secton already exist?
if (modules == null)
{
// If not, add it...
modules = new HttpModulesSection();
ConfigurationSectionGroup group = config.GetSectionGroup("system.web");
// Does the system.web Section already exist?
if (group == null)
{
// If not, add it...
config.SectionGroups.Add("system.web", new ConfigurationSectionGroup());
group = config.GetSectionGroup("system.web");
}
if (group != null)
{
group.Sections.Add("httpModules", modules);
}
}
//<add name="DirectRequestModule" type="Ext.Net.DirectRequestModule, Ext.Net" />
HttpModuleAction action2 = new HttpModuleAction("DirectRequestModule", "Ext.Net.DirectRequestModule, Ext.Net");
// Does the ResourceHandler already exist?
if (modules.Modules.IndexOf(action2) < 0)
{
// If not, add it...
modules.Modules.Add(action2);
config.Save();
}
}
// added by mohghaderi 02 May 2011
internal static bool IsChangeRequiredToWebConfig(IWebApplication app)
{
Configuration config = app.OpenWebConfiguration(true);
HttpHandlersSection handlers = (HttpHandlersSection)config.GetSection("system.web/httpHandlers");
// Does the httpHandlers Secton already exist?
if (handlers == null)
{
return true;
}
HttpHandlerAction action = new HttpHandlerAction("*/ext.axd", "Ext.Net.ResourceHandler", "*", false);
// Does the ResourceHandler already exist?
if (handlers.Handlers.IndexOf(action) < 0)
{
return true;
}
HttpModulesSection modules = (HttpModulesSection)config.GetSection("system.web/httpModules");
// Does the httpModules Secton already exist?
if (modules == null)
{
return true;
}
//<add name="DirectRequestModule" type="Ext.Net.DirectRequestModule, Ext.Net" />
HttpModuleAction action2 = new HttpModuleAction("DirectRequestModule", "Ext.Net.DirectRequestModule, Ext.Net");
// Does the ResourceHandler already exist?
if (modules.Modules.IndexOf(action2) < 0)
{
return true;
}
return false;
}
2- Ext.Net\Core\ResourceHandler.cs
public static GlobalConfig GetExtNetSection(ISite site)
{
if (site != null)
{
IWebApplication app = (IWebApplication)site.GetService(typeof(IWebApplication));
if (app != null)
{
Configuration config = app.OpenWebConfiguration(true); // changed by mohghaderi 02 May 2011
if (config != null)
{
ConfigurationSection section = config.GetSection("extnet");
if (section != null)
{
return section as GlobalConfig;
}
}
}
}
return null;
}
Here is attachments: ResourceHandler.txt WebConfigUtils.txtIt's nice if you could submit these changes to your newer version of Coolite. Thank you for your time and consideration.
Best
Last edited by geoffrey.mcgill; May 31, 2011 at 4:48 PM.
Reason: [FIXED]