'AspCompat' attribute not allowed

J

Jonathan

I'm trying to move a asp.net website to a new site hosted by Godaddy.com.
When I try to browse and aspx page with ADO in it, I get:

Parser Error Message: The current trust level does not allow use of the
'AspCompat' attribute

Source Error:

Line 29: </head>
Line 30:
Line 31: <%@ Page language="VB" Debug="true" aspcompat="True" %>


Godaddy said on the phone they don't allow aspcompat="True". I assume I need
it for the code that says:

sPath = "D:\inetpub\www\myuser\fpdb\db.mdb"
Cnxn = Server.CreateObject("ADODB.Connection")
Cnxn.open("Provider=Microsoft.Jet.OLEDB.4.0;" & "Persist Security
Info=TRUE;" & "Data Source=" & sPath, "Admin", "")

What are the options? Is there another line of code I can add to make it
work somehow?

TIA
 
P

Peter Bromberg [C# MVP]

GoDaddy.com is notorious for the ridiculous and inappropriate restrictions
they put on hosted sites. I once started a site with them and it wouldn't
even allow an outbound HttpWebRequest. They never disclose ANY of this
information up front - you have to find out "after the fact".
My advice? Find another hosting company right away and cut your losses.

-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net
 
R

Rick Strahl

Peter's right - run away from GoDaddy if you think you have any code that
requires security settings. They are horribly inflexible and will not work
with you to get security issues resolved.

However your particular problem is due to using COM for ADO data access. You
can change your code to use ADO.NET instead and use the ADO.NET OleDb
provider instead. It will require code changes.

I assume you're migrating some older ASP classic code if you're using the
COM ADO classes. If rewriting for ADO.NET is not an option you'd probably be
much better off using classic ASP which will perfom better with the COM
objects than ADO.NET will and would let you get around the security issues.

+++ Rick ---
 
J

Jonathan

Thanks.

When you say "It will require code changes", I wonder if you can help me
identify them? This is what I have:

<%@ Page language="VB" Debug="true" aspcompat="True" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

sPath = "D:\inetpub\www\myuser\fpdb\db.mdb"
Cnxn = Server.CreateObject("ADODB.Connection")
Cnxn.open("Provider=Microsoft.Jet.OLEDB.4.0;" & "Persist Security
Info=TRUE;" & "Data Source=" & sPath, "Admin", "")

rs = server.createobject("adodb.recordset")
rs.open(strSQLChange, Cnxn, 2, 2)

If rs.EOF Then 'No records
bolLoggedIn = False
Else
bolLoggedIn = True
strCookieFirstName = rs("UserFirstName").Value
strCookieLastName = rs("UserLastName").Value
strLoggedInEmailAddress = strEmailAddress
End If

rs.Close
rs = Nothing
Cnxn.Close
Cnxn = Nothing
 
S

Steven Cheng

Hi Jonathan,

Yes, as other members have suggested, the error is due to the current .NET
Code access security level of your ASP.NET application is restricted and
does not allow you to use "AspCompat" attribute on aspx page. This is a
common problem when you host page in a publish web hoster. If the webhoster
will not allow elevated code access security, I'm afraid you may consider
migrating those ASPCOMPAT page's code to .NET code so as to avoid the
problem.

Here are some reference about Code Access Security and ASP.NET:

#How To: Use Code Access Security in ASP.NET 2.0
http://msdn2.microsoft.com/en-us/library/ms998326.aspx

#ASP.NET Code Access Security
http://msdn2.microsoft.com/en-us/library/87x8e4d1.aspx

Hope also helps some.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
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.

--------------------
 
S

Steven Cheng

Hi Jonathan,

From the code you provided, you're still using the VB6 ADO objects to
connect access database. In .net framework you can use the new OleDb
provider:

#Walkthrough: Editing an Access Database with ADO.NET
http://msdn2.microsoft.com/en-us/library/ms971485.aspx

However, as far as I know, OleDBProvider also require Full permission trust
level (for CAS settings), mentioned in the article I mentioned earlier:

#How To: Use Code Access Security in ASP.NET 2.0
http://msdn2.microsoft.com/en-us/library/ms998326.aspx

therefore, I'm afraid the host provider's policy restriction become the
main bottleneck here.

Regards,

Steven Cheng
Microsoft MSDN Online Support Lead

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
From: "Jonathan" <[email protected]>
References: <[email protected]>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top