Saturday, March 31, 2012
SubSonic web.config problem
I'm using SubSonic tool, and my website works fine on my machine. When I try to host my website on my hosting account, I get web.config error:
-- ERROR --
Server Error in '/' Application.
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
...
Line 25: <SubSonicService defaultProvider="MYWebsiteDB">
-- ERROR --
- Here's the full web.config file.
Thanks!
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
<section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" allowDefinition="MachineToApplication" restartOnExternalChanges="true" requirePermission="false"/>
</configSections>
<connectionStrings>
<add name="MyWebsiteConnection" connectionString="Data Source=localhost\SQL2005;Database=MyWebsiteDB;User ID=myUser;Password=myPass;"
providerName="System.Data.SqlClient" />
</connectionStrings>
<SubSonicService defaultProvider="MyWebsiteSQL">
<providers>
<add name="MyWebsiteSQL" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="MyWebsiteConnection" generatedNamespace="MyWebsite.DataAccess" fixPluralClassName="true"/>
</providers>
</SubSonicService>
<appSettings>
<add key="SupplierFilePath" value="~/admin/SuppliersFiles/"/>
<add key="SupplierFilePathTemp" value="~/admin/SuppliersFiles/Temp/"/>
</appSettings>
<system.web>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</controls>
</pages>
<compilation debug="true">
<assemblies>
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add assembly="System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Messaging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Configuration.Install, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></assemblies>
</compilation>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
<authentication mode="Forms">
</authentication>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</handlers>
</system.webServer>
<system.net>
<mailSettings>
<smtp>
<network host="localhost" port="25" userName="" password=""/>
</smtp>
</mailSettings>
</system.net>
</configuration>You have a virtual directory under a virtual directory with a web.config in it. Am I right?
Wednesday, March 28, 2012
sub-web.config
ok, i have a web.config in my main solution directory and i have a web.config in a subdirectory. the only other files in the subdirectory are web user controls, but i would like the web.config in there to be used, as well as the web.config in the main solution directory.
is this possible? I'm not calling any aspx files from the subdir, just using the web user controls from there in other aspx's.
matt.
I don't know, I would think not, because the user controls would be a control in the pages control tree, and such, would probably use the main web.config. Only pages I believe would use a sub web.config.Just try it out to see if it works.
Personally I think that user controls are merged with your page and so the user controls runs in the web.config of that folder where the webform resides. Of course, I could be wrong on that one because I didn't test it.
Grz, Kris.
http://weblogs.asp.net/pwilson/archive/2003/04/09/5261.aspx
I see that it can be done. But I can't get it to work - my .NET just doesn't appear to read the subconfig file. My code looks just like in the page linked above!
The link you provided explains how to put configuration data in an external config file (YourSettings.config) and link to that file from the web.config. It has nothing to do with your original question.
Grz, Kris.
yes it does; it's one potential solution...
"i would like the web.config in there to be used, as well as the web.config in the main solution directory"
if it can be made to work.
i'm not going to *** semantics here - what i'm looking for, now, is how to get this apparently wonderful appSettings attribute to work.
Tuesday, March 13, 2012
switch connection string in xsd file
Hi,
I have 2 connectionstrings in the web.config file in my website. It has a xsd file of handling all the database calls etc.
I wonder how do I switch the connectionstring used in the xsd file in code-behind?
Basically, my web.config will have a setting indicates whether website is test mode or live mode in appSetting region:
<add key="mode" value="">
So:
<add key="mode" value="test"> <!--is testing mode-->
<add key="mode" value="live"> <!--is live mode-->
depend on this than the whole site is using the appropriate connection string, sample code:
public static string ConnectionString
{
get
{
if (IsTesting)
{
return ConfigurationManager.ConnectionStrings["Test"].ToString();
}
else
{
return ConfigurationManager.ConnectionStrings["Live"].ToString();
}
}
}
But how to you set the xsd file following this rule?
Thanks in advance.
Hi,
As far as I can see, we don't use .xsd file to switch this. From your code, I can see that your ConfigurationManager is reading from web.config for the targeted connectionstring directly. So the only thing we need to do is to set the IsTesting flag. I think you can add a new key in Web.Config to indicate if the testing mode is true or false.