Hi Madison,
From your description, when you try using a custom webserver control(in a
separate class library assembly) as global registered control in web site
application, you encoutner "request for
'System.web.AspNetHostingPermission'" error ,correct?
Regarding on this error message, I've ever seen some former threads & cases
discussing on the similar problem, and most of them are caused by .NET cas
code access security problem. So far I haven't found any different between
"web site project" and " web application project" on this custom control
behavior. Here are some causes you can check based on those former issues I
found:
** You're referencing a 3rd party or external assembly which is compiled
through .NET 1.X
** Your ASP.NET web application is not in "Full Trust" CAS level while your
custom web control require Full Trust hoster
** Your ASP.NET web application web directory is on a UNC share that cause
your ASP.NET application code be evaluated as Intranet zone (not full trust)
Also, I've performed a very simple test as below:
1) create a custom control class library that contains a custom control
derived from TextBox (no additional code)
2) create an ASP.NET 2.0 web site project and reference the class
library(created in #1)
3) use <pages><controls> to register the control as global one and use it
in page
the test applciation runs ok without problem. BTW, I use a file server(test
server) project, If you're using IIS server, please feel free to let me
know.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Madison - 19 Jun 2007 14:09 GMT
Hi Steven,
Thank you for your reply.
It is very helpful. I did created Web Application project under my localhost
when I created Web Site project was under development server site (IIS
server). So I did tried to create Web Site project under my localhost I did
not have any problem with my custom textbox at all.
What should I do to have full trust on development site server ?
Do I will have any problems when I deploy this project to production web
site server?
I did not get any popup from
Thank you for your advise.
> Hi Madison,
>
[quoted text clipped - 66 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
Steven Cheng[MSFT] - 21 Jun 2007 03:57 GMT
Hi Madison,
Thanks for your reply.
So based on your further information, the problem occurs when you use an
web site application that hosted in local IIS server, correct?
I think you can check your IIS application virtual directory's directory
path, whether it is under the default wwwroot location or pointed to an
external directory path(such as to a user's "MyDocument path" or to a
remote UNC share? If the IIS virtual directory's physical path is from a
non-local directory(such as a unc share) ,it may be evaluated as
non-FullTrust context. Also, you can add the following configuration
setting in your application's web.config to force the application level CAS
permission be configured as "FullTrust" level.
=============
........
<trust level="Full"/>
</system.web>
==================
In addition, you can also try creating other new web application in IIS to
test the same behavior.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Steven Cheng[MSFT] - 25 Jun 2007 13:07 GMT
Hi Madison,
How are you doing on this? Does the further reply helps you some? If there
is anything else we can help, please feel free to post here.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Madison - 25 Jun 2007 14:32 GMT
Hi Steven,
Sorry for delay your response.
I have tried to add <trust level="Full" /> in web.config and yes the IIS
application virtual directory's directory path is pointed to a remote UNC
share which all our web pages and applications reside. I still get the
message say
Element 'myControl' is not a known element. This can occur if there is a
compilation error in the Web site
and the properties did not show when I start to type.
Thank you for your help.
Madison
Steven Cheng[MSFT] - 27 Jun 2007 03:12 GMT
Thanks for your reply Madison,
Well, I think the fact that IIS virtual directory's home path pointing to a
remote UNC share is a important hints. As I mentioned earlier, for UNC
share path, .net framework CAS policy will evaluate it as "Local Intranet"
zone which is not of "FullTrust" permission. You need to add a new
codegroup in machine level CAS policy and grant full permission to it. The
detailed steps is as below:
** In server's control panel->administrative tools, start ".NET 2.0
CONFIGURATION " tool
**In left view, select "Mycomputer--> Runtime security policy--->
machine--->code g roups" node
**You can add a new code group under the "All_Code" group, give it a name.
In the "condition for this code group", select "Url" and input your remote
UNC share's path in it (as below):
\\servername\sharename\*
In "PermissionSet" , give it "FullTrust"
Save it and run your application again to see the behavior. Here is a web
article introducing .NET CAS and how to configure codegroup setting.
#Configuring .NET Code Access Security
http://www.15seconds.com/issue/040121.htm
and for ASP.NET specific code access information, you can have a look at
the following articles:
#Chapter 9 ¨C Using Code Access Security with ASP.NET
http://msdn2.microsoft.com/En-US/library/aa302425.aspx
#How To: Use Code Access Security in ASP.NET 2.0
http://msdn2.microsoft.com/en-us/library/ms998326.aspx
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.