I created a web site, using VS2005 and Asp.Net 2.0, which is working fine in my computer.
I then compiled the web site and uploaded it to my server.
Everything works fine but I can't access to a page: News.aspx. I get the 500 browser error!
This page works fine in my computer and I can't find anything else different in it then in othe pages.
The error I get is:
------------------
Server Error in '/' Application.
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Configuration.ConfigurationPermission, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SecurityException: Request for the permission of type 'System.Configuration.ConfigurationPermission, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessPermission.Demand() +59
System.Configuration.BaseConfigurationRecord.CheckPermissionAllowed(String configKey, Boolean requirePermission, Boolean isTrustedWithoutAptca) +65
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210
------------------
Does anyone has any idea of what is going on here?
I allready tried everything I could think of.
Thanks,
MiguelSeen this error more than once. Actually your hosting company has a different security than your computer, look at the News.aspx, are you trying to write or read something from a file? What are you doing different? You can normally override that on the web.config, post the code behind on News.aspx.cs and I may be able to help you finding out what could be doing that.
The issue is MOST DEFINITELY an issue with your web host, although it's not an issue, more of their settings and what they allow, and it's clearly said in the error when it says
"Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file."
Not really sure where the question there is.. whatever you are trying to do is locked down by your host....this topic at the host i use has some good info on "medium trust"
good luck...
albertpascual:
Seen this error more than once. Actually your hosting company has a different security than your computer, look at the News.aspx, are you trying to write or read something from a file? What are you doing different? You can normally override that on the web.config, post the code behind on News.aspx.cs and I may be able to help you finding out what could be doing that.
That is the strange thing. I am not doing nothing more then usual.
Well, the only thing that might be different would be:
Dim from As String =CType(Web.Configuration.WebConfigurationManager.GetWebApplicationSection("system.net/mailSettings/smtp"),Net.Configuration.SmtpSection).From
In this web site I am working in VB.
Here is the code behind:
' -- [Classes] --------------
' News
Partial Class News
Inherits _BaseMaster
' -- [Page] --------------
Sub Page_PreInit(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.PreInit
' -- [Controls SkinIds] --------------
End Sub
Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Init
End Sub
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim from As String = CType(Web.Configuration.WebConfigurationManager.GetWebApplicationSection("system.net/mailSettings/smtp"), Net.Configuration.SmtpSection).From
End Sub
' -- [Functions] --------------
Private Sub article_DataBinding()
' Display news article
If Not String.IsNullOrEmpty(HttpContext.Current.Request.QueryString("ArticleId")) Then
' Create by27aNews article
Dim by27aNews As New Article
' Define by27aNews properties
With by27aNews
.ConnectionString = ConfigurationManager.ConnectionStrings("dbAccess_JaquelineRoxoAtelier").ConnectionString
.Culture = System.Threading.Thread.CurrentThread.CurrentCulture.ToString()
.Id = Request.QueryString("ArticleId")
.Query = "web_News_SELECT_One"
.Load()
End With
' Create and format article's publication date
Dim articlePubDate As String = DateTime.Parse(by27aNews.PubDate).ToString(Resources.FormatString.DateTime_Full)
articlePubDate = Left(articlePubDate, 1).ToUpper & Right(articlePubDate, Len(articlePubDate) - 1)
' Bind article image
With iArticle
.AlternateText = by27aNews.Title
.ImageUrl = "~/Assets_Content/News/" & System.Threading.Thread.CurrentThread.CurrentCulture.ToString() & "/Images/" & by27aNews.Image
.ToolTip = by27aNews.Title
End With
' Bind article label
With lArticle
.Text = "<h1>" & by27aNews.Title & "</h1>" & _
"<p class=""pubDate"">" & articlePubDate & "</p>" & _
"<p class=""description"">" & by27aNews.Description & "</p>" & _
"<p class=""author"">" & by27aNews.Author.Split(New Char() {"(", ")"})(1) & "</p>"
End With
End If
End Sub
' -- [ASP.Net Controls] --------------
' ASP.Net Image | <Asp:Image
Private Sub iArticle_Init(ByVal sender As Object, ByVal e As EventArgs) Handles iArticle.Init
' Define iArticle properties
With iArticle
.CssClass = "iArticle"
.ImageAlign = ImageAlign.Right
End With
End Sub
' ASP.Net Label | <Asp:Label
Private Sub lArticle_Init(ByVal sender As Object, ByVal e As EventArgs) Handles lArticle.Init
' Define lArticle properties
With lArticle
.CssClass = "lArticle"
End With
End Sub
End Class
Thanks,
Miguel
Looks like you found it yourself, I bet you don't have access to that: Dim from As String = CType(Web.Configuration.WebConfigurationManager.GetWebApplicationSection("system.net/mailSettings/smtp"), Net.Configuration.SmtpSection).From
Take it out, re-publish and test it, if it works without, then go to your hosting company and send them a WTF email
Let me know
0 comments:
Post a Comment