Showing posts with label vs2005. Show all posts
Showing posts with label vs2005. Show all posts

Saturday, March 31, 2012

Strange Behavior for Pages Named Default.aspx

I have several asp.net 2.0 apps written in VS2005 in C#. For each one,
I like to create and track page view events, increment counters, etc.
I do this in a block on each page, like this...
protected void Page_Load(object sender, EventArgs e)
{
if(!this.Page.IsPostBack)
{
Event.Write(EventSource.UserActivity,EventType.Informational,"My
event text");
Counter.Hit(WebPage.MyPage);
}
}
Now, for the problem. I noticed that many events are being written
twice, and many counters are being incremented twice when viewing the
page only once. When I set a breakpoint inside the code block above,
for any page named "Default.aspx" (no matter where it is in the folder
structure) the lines inside the code block execute twice. If I rename
the page to something else, they execute only once, as expected.
Does anyone know what causes this? How can I fix it?Hi Joey,
Seems page events are fired twice because event handler is assigned two
times - by the AutoWireupEvent directive and by your code by adding the
handler explicitely (vb.net AddHandler or Handles clauses)
Milosz
"Joey" wrote:

> I have several asp.net 2.0 apps written in VS2005 in C#. For each one,
> I like to create and track page view events, increment counters, etc.
> I do this in a block on each page, like this...
> protected void Page_Load(object sender, EventArgs e)
> {
> if(!this.Page.IsPostBack)
> {
> Event.Write(EventSource.UserActivity,EventType.Informational,"My
> event text");
> Counter.Hit(WebPage.MyPage);
> }
> }
> Now, for the problem. I noticed that many events are being written
> twice, and many counters are being incremented twice when viewing the
> page only once. When I set a breakpoint inside the code block above,
> for any page named "Default.aspx" (no matter where it is in the folder
> structure) the lines inside the code block execute twice. If I rename
> the page to something else, they execute only once, as expected.
> Does anyone know what causes this? How can I fix it?
>
On Jun 27, 5:38 pm, Milosz Skalecki [MCAD] <mily...@.DONTLIKESPAMwp.pl>
wrote:
> Hi Joey,
> Seems page events are fired twice because event handler is assigned two
> times - by the AutoWireupEvent directive and by your code by adding the
> handler explicitely (vb.net AddHandler or Handles clauses)
> --
> Milosz
>
> "Joey" wrote:
>
>
>
> - Show quoted text -
My code does not explicitly assign any event handlers.
Hi again Joey,
I hope you are well. Could you please paste both aspx page and code beside
so we could have a look?
--
Milosz
"Joey" wrote:

> On Jun 27, 5:38 pm, Milosz Skalecki [MCAD] <mily...@.DONTLIKESPAMwp.pl>
> wrote:
> My code does not explicitly assign any event handlers.
>

Strange Behavior for Pages Named Default.aspx

I have several asp.net 2.0 apps written in VS2005 in C#. For each one,
I like to create and track page view events, increment counters, etc.
I do this in a block on each page, like this...

protected void Page_Load(object sender, EventArgs e)
{
if(!this.Page.IsPostBack)
{
Event.Write(EventSource.UserActivity,EventType.Inf ormational,"My
event text");
Counter.Hit(WebPage.MyPage);
}
}

Now, for the problem. I noticed that many events are being written
twice, and many counters are being incremented twice when viewing the
page only once. When I set a breakpoint inside the code block above,
for any page named "Default.aspx" (no matter where it is in the folder
structure) the lines inside the code block execute twice. If I rename
the page to something else, they execute only once, as expected.

Does anyone know what causes this? How can I fix it?Hi Joey,

Seems page events are fired twice because event handler is assigned two
times - by the AutoWireupEvent directive and by your code by adding the
handler explicitely (vb.net AddHandler or Handles clauses)

--
Milosz

"Joey" wrote:

Quote:

Originally Posted by

I have several asp.net 2.0 apps written in VS2005 in C#. For each one,
I like to create and track page view events, increment counters, etc.
I do this in a block on each page, like this...
>
protected void Page_Load(object sender, EventArgs e)
{
if(!this.Page.IsPostBack)
{
Event.Write(EventSource.UserActivity,EventType.Inf ormational,"My
event text");
Counter.Hit(WebPage.MyPage);
}
}
>
Now, for the problem. I noticed that many events are being written
twice, and many counters are being incremented twice when viewing the
page only once. When I set a breakpoint inside the code block above,
for any page named "Default.aspx" (no matter where it is in the folder
structure) the lines inside the code block execute twice. If I rename
the page to something else, they execute only once, as expected.
>
Does anyone know what causes this? How can I fix it?
>
>


On Jun 27, 5:38 pm, Milosz Skalecki [MCAD] <mily...@.DONTLIKESPAMwp.pl>
wrote:

Quote:

Originally Posted by

Hi Joey,
>
Seems page events are fired twice because event handler is assigned two
times - by the AutoWireupEvent directive and by your code by adding the
handler explicitely (vb.net AddHandler or Handles clauses)
>
--
Milosz
>
>
>
"Joey" wrote:

Quote:

Originally Posted by

I have several asp.net 2.0 apps written in VS2005 in C#. For each one,
I like to create and track page view events, increment counters, etc.
I do this in a block on each page, like this...


>

Quote:

Originally Posted by

protected void Page_Load(object sender, EventArgs e)
{
if(!this.Page.IsPostBack)
{
Event.Write(EventSource.UserActivity,EventType.Inf ormational,"My
event text");
Counter.Hit(WebPage.MyPage);
}
}


>

Quote:

Originally Posted by

Now, for the problem. I noticed that many events are being written
twice, and many counters are being incremented twice when viewing the
page only once. When I set a breakpoint inside the code block above,
for any page named "Default.aspx" (no matter where it is in the folder
structure) the lines inside the code block execute twice. If I rename
the page to something else, they execute only once, as expected.


>

Quote:

Originally Posted by

Does anyone know what causes this? How can I fix it?- Hide quoted text -


>
- Show quoted text -


My code does not explicitly assign any event handlers.
Hi again Joey,

I hope you are well. Could you please paste both aspx page and code beside
so we could have a look?
--
Milosz

"Joey" wrote:

Quote:

Originally Posted by

On Jun 27, 5:38 pm, Milosz Skalecki [MCAD] <mily...@.DONTLIKESPAMwp.pl>
wrote:

Quote:

Originally Posted by

Hi Joey,

Seems page events are fired twice because event handler is assigned two
times - by the AutoWireupEvent directive and by your code by adding the
handler explicitely (vb.net AddHandler or Handles clauses)

--
Milosz

"Joey" wrote:

Quote:

Originally Posted by

I have several asp.net 2.0 apps written in VS2005 in C#. For each one,
I like to create and track page view events, increment counters, etc.
I do this in a block on each page, like this...


Quote:

Originally Posted by

protected void Page_Load(object sender, EventArgs e)
{
if(!this.Page.IsPostBack)
{
Event.Write(EventSource.UserActivity,EventType.Inf ormational,"My
event text");
Counter.Hit(WebPage.MyPage);
}
}


Quote:

Originally Posted by

Now, for the problem. I noticed that many events are being written
twice, and many counters are being incremented twice when viewing the
page only once. When I set a breakpoint inside the code block above,
for any page named "Default.aspx" (no matter where it is in the folder
structure) the lines inside the code block execute twice. If I rename
the page to something else, they execute only once, as expected.


Quote:

Originally Posted by

Does anyone know what causes this? How can I fix it?- Hide quoted text -


- Show quoted text -


>
My code does not explicitly assign any event handlers.
>
>

Saturday, March 24, 2012

Strange error in Asp.Net 2.0

Hello,

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 emailSmile

Let me know

Tuesday, March 13, 2012

Strange problem on database update

Does anyone have this problem before, I was developing asp.net 2.0 using VS
2005, everything works fine, I had used "Publish Web Site" to deploy my app.
on local machine's IIS, works as I expected too.
But today, when I use same method to deploy my solution on my IIS, while I
do the testing, any function which requires performing action query on my
Access DB, the web page displayed following error:
Operation must use an updateable query
Exception Details: System.Data.OleDb.OleDbException: Operation must use an
updateable query.
Other than that, all "retrieve" data operation to display records on web
pages had no problem. If I use VS 2005 to run my app. this problem does not
occur, I had also copy the same folder of IIS to another machine, this
problem doesn't occur.
Does anyone know what would be the problem on my IIS or something else?This must be a security problem. If the process does not have access to
Change the MDB (or MDE) Access file then the database becomes read-only
and you cannot update. Make sure that the ASPNET local account in the
computer were IIS is running has Change rights on the MDB or MDE file.
Hope this helps.
thanks very much, you are absolutely right. I'm using WinXP as my IIS
platform for testing, once i share the web site's folder to "Allow network
users to change my files", the update operation working now!
If I don't want to share the directory this way. You mentioned setting
ASPNET local account to have change rights! how do you properly do this in
Win XP?
"Neutrino" <neo_virtual@.yahoo.com> wrote in message
news:1145249072.160245.235360@.v46g2000cwv.googlegroups.com...
> This must be a security problem. If the process does not have access to
> Change the MDB (or MDE) Access file then the database becomes read-only
> and you cannot update. Make sure that the ASPNET local account in the
> computer were IIS is running has Change rights on the MDB or MDE file.
> Hope this helps.
>
goodie, i went to my IIS root directory (C:\Inetpub\wwwroot) to add ASPNet
account to have write permission, which i think is a more proper way of
setting it up!
thanks for your help anyway!
"Neutrino" <neo_virtual@.yahoo.com> wrote in message
news:1145249072.160245.235360@.v46g2000cwv.googlegroups.com...
> This must be a security problem. If the process does not have access to
> Change the MDB (or MDE) Access file then the database becomes read-only
> and you cannot update. Make sure that the ASPNET local account in the
> computer were IIS is running has Change rights on the MDB or MDE file.
> Hope this helps.
>

Strange problem on database update

Does anyone have this problem before, I was developing asp.net 2.0 using VS
2005, everything works fine, I had used "Publish Web Site" to deploy my app.
on local machine's IIS, works as I expected too.

But today, when I use same method to deploy my solution on my IIS, while I
do the testing, any function which requires performing action query on my
Access DB, the web page displayed following error:

Operation must use an updateable query
Exception Details: System.Data.OleDb.OleDbException: Operation must use an
updateable query.

Other than that, all "retrieve" data operation to display records on web
pages had no problem. If I use VS 2005 to run my app. this problem does not
occur, I had also copy the same folder of IIS to another machine, this
problem doesn't occur.

Does anyone know what would be the problem on my IIS or something else?This must be a security problem. If the process does not have access to
Change the MDB (or MDE) Access file then the database becomes read-only
and you cannot update. Make sure that the ASPNET local account in the
computer were IIS is running has Change rights on the MDB or MDE file.

Hope this helps.
thanks very much, you are absolutely right. I'm using WinXP as my IIS
platform for testing, once i share the web site's folder to "Allow network
users to change my files", the update operation working now!

If I don't want to share the directory this way. You mentioned setting
ASPNET local account to have change rights! how do you properly do this in
Win XP?

"Neutrino" <neo_virtual@.yahoo.com> wrote in message
news:1145249072.160245.235360@.v46g2000cwv.googlegr oups.com...
> This must be a security problem. If the process does not have access to
> Change the MDB (or MDE) Access file then the database becomes read-only
> and you cannot update. Make sure that the ASPNET local account in the
> computer were IIS is running has Change rights on the MDB or MDE file.
> Hope this helps.
goodie, i went to my IIS root directory (C:\Inetpub\wwwroot) to add ASPNet
account to have write permission, which i think is a more proper way of
setting it up!

thanks for your help anyway!

"Neutrino" <neo_virtual@.yahoo.com> wrote in message
news:1145249072.160245.235360@.v46g2000cwv.googlegr oups.com...
> This must be a security problem. If the process does not have access to
> Change the MDB (or MDE) Access file then the database becomes read-only
> and you cannot update. Make sure that the ASPNET local account in the
> computer were IIS is running has Change rights on the MDB or MDE file.
> Hope this helps.