Last post Apr 27, 2005 03:55 PM by DeferentGecko
Mar 31, 2005 08:15 AM|DeferentGecko|LINK
Line 64: string themeDir = ConfigurationSettings.AppSettings["ThemeDirectory"];Line 65: Line 66: header = (UserControl) Page.LoadControl(themeDir + @"\SkinControls\header.ascx");Line 67: footer = (UserControl) Page.LoadControl(themeDir + @"\SkinControls\footer.ascx");Line 68:
Mar 31, 2005 07:55 PM|danmor|LINK
We need more information. What version of ASP.NET are you using? Have you successfully launched Cassini with a simple 1-page web, or is your app "OpenWebmail.net" the first application you tried to launch under Cassini?
Did you see any errors building Cassini sample, and registering Cassini.dll in the GAC? First, follow the steps in the 6-02-04 post if you have any problems compiling the sample application.
Next, if Cassini compiled and registered OK, try a one-page sample application, just a default.aspx with a simple server-side code snippet such as
Lastly, try your application again, and if it still gives an error let us know the command you are using to launch Cassini.
Apr 01, 2005 02:58 PM|DeferentGecko|LINK
Apr 05, 2005 06:13 PM|danmor|LINK
Apr 06, 2005 04:54 AM|DeferentGecko|LINK
Apr 08, 2005 07:04 PM|danmor|LINK
I tried your code, but it wouldn't compile because I don't have 'CredentialsProvider', but even after I commented that out it wouldn't compile because I don't have your 'ThemeDirectory" app settings or user controls.
I think I see what you are trying to do. I created a new C# web application in VS 2003. I added a user control to a 'Themes' directory on my web root, and I was able to add it to my page dynamically in Page_Load() with this code:
The page ran fine in IIS, and in the Cassini Sample Web Server. In your case I suspect Cassini might not be correctly creating the path to your user controls. Have you tried hard-coding a path to the ascx files?
Apr 09, 2005 01:55 PM|DeferentGecko|LINK
Apr 12, 2005 02:16 PM|danmor|LINK
If Cassini is calculating the value of
themeDir + @"\SkinControls\header.ascx"); differently than IIS does then let us know because I would like to try it with Visual Web Developer to see if the ASP.NET Development Server has the same issue.
Apr 18, 2005 03:12 PM|DeferentGecko|LINK
Apr 18, 2005 04:57 PM|DeferentGecko|LINK
Apr 18, 2005 05:35 PM|danmor|LINK
Apr 19, 2005 11:24 AM|DeferentGecko|LINK
Apr 19, 2005 10:20 PM|danmor|LINK
Ah, that's your problem. The combined relative path "../Themes/Invision/\SkinControls\header.ascx" is invalid in both IE and Mozilla Firefox. When I say 'invalid' I mean 'resolves to the wrong location'. I found two work-arounds:
1) Remove trailing slash on ThemeDirectory ("../Themes/Invision"). This worked for me with IE, but not Firefox
2) Change .. to ~ to make path root relative ("~/Themes/Invision/"), which worked for me with IE and Firefox
Apr 20, 2005 02:43 AM|DeferentGecko|LINK
Apr 20, 2005 03:14 PM|danmor|LINK
The problem is that the path to that control on the server side is incorrect (forward slash followed by a back slash). You need to correct the path to that control. Because your path is created by combining two strings, you need to change the ThemeDirectory
string. Then your control will be found and loaded on the page. It will only take a minute to test both possible solutions.
Apr 21, 2005 11:24 AM|DeferentGecko|LINK
Apr 25, 2005 03:54 PM|DanEwalt|LINK
I have to agree with the previous posts pertaining to the path that you are using to load the control.
I have an application that uses LoadControl in multiple places in multiple pages. This runs both under IIS and my own server ( based on Cassini ).
Here is the path I use in the web.config for one of the controls as an example:
<add key="settings" value="~/UserControls/SettingsContainer.ascx"/>
<!-- Other user controls here -->
and here is the code I user to load that control:
Sorry about the formatting the window here is a little restrictive.
if( ! IsPostBack )
control = LoadControl(
( ( NameValueCollection ) ConfigurationSettings.GetConfig ( "usercontrols" ) )[ "settings" ]
control.ID = "ctlSettings";
dphMain.Controls.Add( control );
dphMain is just an enhanced control container, code to add to the pages controls collection would be the same.
So as someone mentioned before use the ~ ( tilde ) to get the relative path to the control directory vs. the method you are using. LoadControl does in fact work in Cassini with no problems. One of the first tests I did :-)
Hope this helps,
Apr 25, 2005 04:20 PM|danmor|LINK
You say "Just tried that". Did you try removing the trailing slash, making the link root relative, or both?
The following link to the ASP.NET security patch for path validation provides more information on allowed paths in web applications. The "..\" which you have in one of your strings is guarded against as a security threat:
MS05-004: ASP.NET path validation vulnerability could allow unauthorized access
Apr 27, 2005 03:55 PM|DeferentGecko|LINK