Showing posts with label following. Show all posts
Showing posts with label following. Show all posts

Saturday, March 31, 2012

Straight ASP in VS.NET Question

All,
I have to set up a web server to handle
the following call:
<server URL>/Submit.asp?parm1={1}&parm2={2}&parm3={3}
I'm pretty lightweight in ASP.NET and a pure noob
in straight ASP. What's the easiest way to set
up a simple server page to grab these three parms
and invoke a method in my managed assembly?
Thank you,
~swoozin the page_load just add some Request.QueryString() calls, maybe a simple
switch() statement.
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"swoozie" <swooziep@.yahoo.com> wrote in message
news:1111071784.152396.227780@.o13g2000cwo.googlegroups.com...
> All,
> I have to set up a web server to handle
> the following call:
> <server URL>/Submit.asp?parm1={1}&parm2={2}&parm3={3}
> I'm pretty lightweight in ASP.NET and a pure noob
> in straight ASP. What's the easiest way to set
> up a simple server page to grab these three parms
> and invoke a method in my managed assembly?
> Thank you,
> ~swooz
>
Curt_C [MVP] wrote:
> in the page_load just add some Request.QueryString() calls, maybe a
simple
> switch() statement.
> --
> Curt Christianson
> Site & Scripts: http://www.Darkfalz.com
> Blog: http://blog.Darkfalz.com
>
Curt, thanks for the reply. I am still unsure
how to handle the "Submit.asp" in the URL. Do
I need to create a straight ASP page to handle
this? And there's the issue with ending up
in managed code with the parm values.
Thanks a lot!
~swooz
It's all yours now, Curt. -)
Kevin Spencer
Microsoft MVP
.Net Developer
What You S Is What You Get.
"swoozie" <swooziep@.yahoo.com> wrote in message
news:1111076028.221406.316920@.f14g2000cwb.googlegroups.com...
> Curt_C [MVP] wrote:
> simple
> Curt, thanks for the reply. I am still unsure
> how to handle the "Submit.asp" in the URL. Do
> I need to create a straight ASP page to handle
> this? And there's the issue with ending up
> in managed code with the parm values.
> Thanks a lot!
> ~swooz
>
huh? that makes little sense to me.....
Is this .ASP or .ASPX where you are trying to read the querystring values?
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"swoozie" <swooziep@.yahoo.com> wrote in message
news:1111076028.221406.316920@.f14g2000cwb.googlegroups.com...
> Curt_C [MVP] wrote:
> simple
> Curt, thanks for the reply. I am still unsure
> how to handle the "Submit.asp" in the URL. Do
> I need to create a straight ASP page to handle
> this? And there's the issue with ending up
> in managed code with the parm values.
> Thanks a lot!
> ~swooz
>
I got the feeling I missed something, but thanks for the warning :}
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:eKvNk0wKFHA.2648@.TK2MSFTNGP14.phx.gbl...
> It's all yours now, Curt. -)
> --
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> What You S Is What You Get.
> "swoozie" <swooziep@.yahoo.com> wrote in message
> news:1111076028.221406.316920@.f14g2000cwb.googlegroups.com...
>
I'm sorry if I wasn't clear. The HTTP GET is from a 3rd-party
client, so I have to handle the URL with ".asp" in it (see above).
If I can handle that with ASP.NET, great! Can I set up a redirect
to an ASPX? Either way, I need to end up with the parms
in a managed assembly, be it web tier or middle. I'm fairly new
to this, so apologies in advance. And thanks so much for the help.
~swooz
One more post to further clarify! ;-)
I am assuming since they're throwing ".asp" at me
that I need to have a classic ASP page on the web
server.
you mean that THEY are pointing to YOUR site like this:
http://www.yoursite.com/submit.asp?parm1={1}&parm2={2}&parm3={3}
If so, few things...
1) wrong group, this is a .NET group.
2) you will need a page on your server called "submit.asp"
3) in that page you will need:
- myValue1 = Request.QueryString("param1")
- myValue2 = Request.QueryString("param2")
- myValue3 = Request.QueryString("param3")
that clarify it for ya?
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"swoozie" <swooziep@.yahoo.com> wrote in message
news:1111079290.380858.246130@.f14g2000cwb.googlegroups.com...
> One more post to further clarify! ;-)
> I am assuming since they're throwing ".asp" at me
> that I need to have a classic ASP page on the web
> server.
>
Yes, it does clarify, thanks. I did the .NET
newsgroup b/c [so far] I've written a pure .NET
app, but it appears I'm gonna have to have
an unmanaged piece in there.
ty

Straight ASP in VS.NET Question

All,

I have to set up a web server to handle
the following call:

<server URL>/Submit.asp?parm1={1}&parm2={2}&parm3={3}

I'm pretty lightweight in ASP.NET and a pure noob
in straight ASP. What's the easiest way to set
up a simple server page to grab these three parms
and invoke a method in my managed assembly?

Thank you,
~swoozin the page_load just add some Request.QueryString() calls, maybe a simple
switch() statement.

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com

"swoozie" <swooziep@.yahoo.com> wrote in message
news:1111071784.152396.227780@.o13g2000cwo.googlegr oups.com...
> All,
> I have to set up a web server to handle
> the following call:
> <server URL>/Submit.asp?parm1={1}&parm2={2}&parm3={3}
> I'm pretty lightweight in ASP.NET and a pure noob
> in straight ASP. What's the easiest way to set
> up a simple server page to grab these three parms
> and invoke a method in my managed assembly?
> Thank you,
> ~swooz
Curt_C [MVP] wrote:
> in the page_load just add some Request.QueryString() calls, maybe a
simple
> switch() statement.
> --
> Curt Christianson
> Site & Scripts: http://www.Darkfalz.com
> Blog: http://blog.Darkfalz.com

Curt, thanks for the reply. I am still unsure
how to handle the "Submit.asp" in the URL. Do
I need to create a straight ASP page to handle
this? And there's the issue with ending up
in managed code with the parm values.

Thanks a lot!
~swooz
It's all yours now, Curt. -)

--

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"swoozie" <swooziep@.yahoo.com> wrote in message
news:1111076028.221406.316920@.f14g2000cwb.googlegr oups.com...
> Curt_C [MVP] wrote:
>> in the page_load just add some Request.QueryString() calls, maybe a
> simple
>> switch() statement.
>>
>> --
>> Curt Christianson
>> Site & Scripts: http://www.Darkfalz.com
>> Blog: http://blog.Darkfalz.com
>>
>>
> Curt, thanks for the reply. I am still unsure
> how to handle the "Submit.asp" in the URL. Do
> I need to create a straight ASP page to handle
> this? And there's the issue with ending up
> in managed code with the parm values.
> Thanks a lot!
> ~swooz
huh? that makes little sense to me.....
Is this .ASP or .ASPX where you are trying to read the querystring values?

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com

"swoozie" <swooziep@.yahoo.com> wrote in message
news:1111076028.221406.316920@.f14g2000cwb.googlegr oups.com...
> Curt_C [MVP] wrote:
>> in the page_load just add some Request.QueryString() calls, maybe a
> simple
>> switch() statement.
>>
>> --
>> Curt Christianson
>> Site & Scripts: http://www.Darkfalz.com
>> Blog: http://blog.Darkfalz.com
>>
>>
> Curt, thanks for the reply. I am still unsure
> how to handle the "Submit.asp" in the URL. Do
> I need to create a straight ASP page to handle
> this? And there's the issue with ending up
> in managed code with the parm values.
> Thanks a lot!
> ~swooz
I got the feeling I missed something, but thanks for the warning :}

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com

"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:eKvNk0wKFHA.2648@.TK2MSFTNGP14.phx.gbl...
> It's all yours now, Curt. -)
> --
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> What You Seek Is What You Get.
> "swoozie" <swooziep@.yahoo.com> wrote in message
> news:1111076028.221406.316920@.f14g2000cwb.googlegr oups.com...
>>
>> Curt_C [MVP] wrote:
>>> in the page_load just add some Request.QueryString() calls, maybe a
>> simple
>>> switch() statement.
>>>
>>> --
>>> Curt Christianson
>>> Site & Scripts: http://www.Darkfalz.com
>>> Blog: http://blog.Darkfalz.com
>>>
>>>
>>
>> Curt, thanks for the reply. I am still unsure
>> how to handle the "Submit.asp" in the URL. Do
>> I need to create a straight ASP page to handle
>> this? And there's the issue with ending up
>> in managed code with the parm values.
>>
>> Thanks a lot!
>> ~swooz
>>
I'm sorry if I wasn't clear. The HTTP GET is from a 3rd-party
client, so I have to handle the URL with ".asp" in it (see above).
If I can handle that with ASP.NET, great! Can I set up a redirect
to an ASPX? Either way, I need to end up with the parms
in a managed assembly, be it web tier or middle. I'm fairly new
to this, so apologies in advance. And thanks so much for the help.

~swooz
One more post to further clarify! ;-)
I am assuming since they're throwing ".asp" at me
that I need to have a classic ASP page on the web
server.
you mean that THEY are pointing to YOUR site like this:

http://www.yoursite.com/submit.asp?parm1={1}&parm2={2}&parm3={3}

If so, few things...
1) wrong group, this is a .NET group.
2) you will need a page on your server called "submit.asp"
3) in that page you will need:
- myValue1 = Request.QueryString("param1")
- myValue2 = Request.QueryString("param2")
- myValue3 = Request.QueryString("param3")

that clarify it for ya?

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com

"swoozie" <swooziep@.yahoo.com> wrote in message
news:1111079290.380858.246130@.f14g2000cwb.googlegr oups.com...
> One more post to further clarify! ;-)
> I am assuming since they're throwing ".asp" at me
> that I need to have a classic ASP page on the web
> server.
Yes, it does clarify, thanks. I did the .NET
newsgroup b/c [so far] I've written a pure .NET
app, but it appears I'm gonna have to have
an unmanaged piece in there.

ty
or get them to point to a .aspx page instead

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com

"swoozie" <swooziep@.yahoo.com> wrote in message
news:1111080239.282185.68350@.l41g2000cwc.googlegro ups.com...
> Yes, it does clarify, thanks. I did the .NET
> newsgroup b/c [so far] I've written a pure .NET
> app, but it appears I'm gonna have to have
> an unmanaged piece in there.
> ty

Strange and annoying problem

Even commenting a line in javascript still prompts for an error. If I remove the following line then no error, but again if i put it back, even commented error occurs.

//opener.document.getElementById('<%=TextBox1.ClientID%>').value='akberalikaka';

isn't it strange behavior

Yes it is strange. As far as i am aware of, there are three types of comment you can do in java:

1. Multiple-line :/* and*/

2.One-line comments of C++ style: Begins with // and continue up to the next line break:

3.One-line comments with theHTML comment-opening sequence (<!--). Note that the JavaScript interpreter ignores the closing characters of HTML comments (-->). Consider this example:
<!-- This is treated as a one-line JS comment<!-- It works just like a comment beginning with //<!-- --> This is also a one-line JS comment<!-- --> because JS ignores the closing characters<!-- --> of HTML-style comments

HTML-style comments are not usually found in the middle of JavaScript code. However, it is recommended to use HTML comments for hiding Javascript code from old browsers

Try using this mate


Hi,

//opener.document.getElementById('<%=TextBox1.ClientID%>').value='akberalikaka';

Your comment in javascript doesn't stop<%=TextBox1.ClientID%> since it is asp.net code. So to clear the error you have to remove this code.


You have to comment the aspnet code also

if you are using C#

//opener.document.getElementById('<%/*=TextBox1.ClientID*/%>').value='akberalikaka';

if you are using VB

//opener.document.getElementById('<%'=TextBox1.ClientID'%>').value='akberalikaka';

<%'=TextBox1.ClientID'%> is equivalent to <% Response.Write(TextBox1.ClientID) %>

Wednesday, March 28, 2012

Strange behaviour in Production environnement

Hello experts,

I have the following peice of code in my Global.asax

void Application_Error(object sender, EventArgs e)

{

//get reference to the source of the exception chain

Log log = new Log();

Exception ex = Server.GetLastError();

log.AddLogEntry(Request, ex);

log.SaveData();

Response.Redirect("~/Error.aspx");

}

This code works well on my test server Win2k3 , IIS 6. It write to my
erro.log text file and displays Error.aspx as expected.

In Production( Win2k3 , IIS 6) , it open the file error.log(Can be seen on
last modified date) but the expection is not written to the file. Neither is
Error.aspx displayed. Can someone tell were i should be looking?

Many thanks in advance .

SHi,

Does asp.net process has write /modify permission on the folder/file that
you are attemting to write? I would also use:
Server.ClearError(); before redirecting.

Regards

Med

"Smith" <Smith@.pricateemail.comwrote in message
news:%23yjQVIQMIHA.5224@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

>
Hello experts,
>
I have the following peice of code in my Global.asax
>
void Application_Error(object sender, EventArgs e)
>
{
>
//get reference to the source of the exception chain
>
Log log = new Log();
>
Exception ex = Server.GetLastError();
>
log.AddLogEntry(Request, ex);
>
log.SaveData();
>
Response.Redirect("~/Error.aspx");
>
>
>
>
>
>
}
>
>
>
This code works well on my test server Win2k3 , IIS 6. It write to my
erro.log text file and displays Error.aspx as expected.
>
>
>
In Production( Win2k3 , IIS 6) , it open the file error.log(Can be seen on
last modified date) but the expection is not written to the file. Neither
is Error.aspx displayed. Can someone tell were i should be looking?
>
>
>
>
>
Many thanks in advance .
>
S
>
>


"Med" <nospam@.nowhere.nowherewrote in message
news:%236KXucQMIHA.4228@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

Hi,
>
Does asp.net process has write /modify permission on the folder/file that
you are attemting to write? I would also use:
Server.ClearError(); before redirecting.
>


The user asp.net process is running under har full permission in the folder
where the code lives.Also note that the modified date of the error file
actually change according to the time error occured. It this was permission
problem, would it be allowed to actually open the file?
How does ServerClear() helps here?

Thanks
S
Hi,

Quote:

Originally Posted by

The user asp.net process is running under har full permission in the
folder where the code lives.


Does the log folder/file resides in this folder?

Actually Server.ClearError(); was irrelavant to your problem here, it was
just a suggestion as it prevents the error from continuing to the
Application_Error event handler.

Could you send the code for AddLogEntry(Request, ex)?

This is how I do it:

<%@. Import Namespace = "System.IO" %>
<%@. Import Namespace = "System.Diagnostics" %>

void Application_Error(object sender, EventArgs e)
{
//Only redirect to error page if in Release mode.
#if DEBUG
{
//Show error details
}
#else
{
try
{
LogError(Server.GetLastError().GetBaseException()) ;
Server.ClearError();
}
catch
{
//Do something....
}

//Redirect to error.aspx page
Response.Redirect("error.aspx");
}
#endif
}

private void LogError(Exception objError)
{

try
{
string sLogFilePathAndName = String.Format(@."{0}{1} {2}.log",
Server.MapPath("~/Logs/"), DateTime.Now.ToLongDateString(),
DateTime.Now.DayOfWeek);
using (StreamWriter sw = File.AppendText(sLogFilePathAndName))
{
sw.WriteLine(Environment.NewLine);
sw.WriteLine(String.Format("Error Caught in Application on
{0} {1} @. {2}", DateTime.Now.DayOfWeek, DateTime.Now.ToLongDateString(),
DateTime.Now.ToLongTimeString()));
sw.WriteLine(String.Format("IP Address: {0}",
Request.ServerVariables["REMOTE_ADDR"].ToString()));
sw.WriteLine(String.Format("Platform: {0}",
Request.Browser.Platform));
sw.WriteLine(String.Format("Browser: {0}",
Request.Browser.Type));
sw.WriteLine(String.Format("Error in: {0}",
Request.Url.ToString()));
sw.WriteLine(String.Format("Error Message: {0}",
objError.Message.ToString()));
sw.WriteLine("Stack Trace:");
sw.WriteLine(objError.StackTrace.ToString());
sw.WriteLine(Environment.NewLine);
sw.WriteLine("--------------------------");
sw.Close();
}
}
catch
{
//Do something....
}
}

You may also want to look at:
http://support.microsoft.com/defaul...kb;en-us;306355
Hope it helps

Med

"Smith" <Smith@.pricateemail.comwrote in message
news:e5iA$HRMIHA.1208@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

>
"Med" <nospam@.nowhere.nowherewrote in message
news:%236KXucQMIHA.4228@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

>Hi,
>>
>Does asp.net process has write /modify permission on the folder/file that
>you are attemting to write? I would also use:
>Server.ClearError(); before redirecting.
>>


>
The user asp.net process is running under har full permission in the
folder where the code lives.Also note that the modified date of the error
file actually change according to the time error occured. It this was
permission problem, would it be allowed to actually open the file?
How does ServerClear() helps here?
>
Thanks
S
>


http://support.microsoft.com/kb/890960

Strange behaviour in Production environnement

Hello experts,
I have the following peice of code in my Global.asax
void Application_Error(object sender, EventArgs e)
{
//get reference to the source of the exception chain
Log log = new Log();
Exception ex = Server.GetLastError();
log.AddLogEntry(Request, ex);
log.SaveData();
Response.Redirect("~/Error.aspx");
}
This code works well on my test server Win2k3 , IIS 6. It write to my
erro.log text file and displays Error.aspx as expected.
In Production( Win2k3 , IIS 6) , it open the file error.log(Can be seen on
last modified date) but the expection is not written to the file. Neither is
Error.aspx displayed. Can someone tell were i should be looking?
Many thanks in advance .
SHi,
Does asp.net process has write /modify permission on the folder/file that
you are attemting to write? I would also use:
Server.ClearError(); before redirecting.
Regards
Med
"Smith" <Smith@.pricateemail.com> wrote in message
news:%23yjQVIQMIHA.5224@.TK2MSFTNGP02.phx.gbl...
> Hello experts,
> I have the following peice of code in my Global.asax
> void Application_Error(object sender, EventArgs e)
> {
> //get reference to the source of the exception chain
> Log log = new Log();
> Exception ex = Server.GetLastError();
> log.AddLogEntry(Request, ex);
> log.SaveData();
> Response.Redirect("~/Error.aspx");
>
>
>
> }
>
> This code works well on my test server Win2k3 , IIS 6. It write to my
> erro.log text file and displays Error.aspx as expected.
>
> In Production( Win2k3 , IIS 6) , it open the file error.log(Can be seen on
> last modified date) but the expection is not written to the file. Neither
> is Error.aspx displayed. Can someone tell were i should be looking?
>
>
> Many thanks in advance .
> S
>
"Med" <nospam@.nowhere.nowhere> wrote in message
news:%236KXucQMIHA.4228@.TK2MSFTNGP02.phx.gbl...
> Hi,
> Does asp.net process has write /modify permission on the folder/file that
> you are attemting to write? I would also use:
> Server.ClearError(); before redirecting.
>
The user asp.net process is running under har full permission in the folder
where the code lives.Also note that the modified date of the error file
actually change according to the time error occured. It this was permission
problem, would it be allowed to actually open the file?
How does ServerClear() helps here?
Thanks
S
Hi,

> The user asp.net process is running under har full permission in the
> folder where the code lives.
Does the log folder/file resides in this folder?
Actually Server.ClearError(); was irrelavant to your problem here, it was
just a suggestion as it prevents the error from continuing to the
Application_Error event handler.
Could you send the code for AddLogEntry(Request, ex)?
This is how I do it:
<%@. Import Namespace = "System.IO" %>
<%@. Import Namespace = "System.Diagnostics" %>
void Application_Error(object sender, EventArgs e)
{
//Only redirect to error page if in Release mode.
#if DEBUG
{
//Show error details
}
#else
{
try
{
LogError(Server.GetLastError().GetBaseException());
Server.ClearError();
}
catch
{
//Do something....
}
//Redirect to error.aspx page
Response.Redirect("error.aspx");
}
#endif
}
private void LogError(Exception objError)
{
try
{
string sLogFilePathAndName = String.Format(@."{0}{1} {2}.log",
Server.MapPath("~/Logs/"), DateTime.Now.ToLongDateString(),
DateTime.Now.DayOfW);
using (StreamWriter sw = File.AppendText(sLogFilePathAndName))
{
sw.WriteLine(Environment.NewLine);
sw.WriteLine(String.Format("Error Caught in Application on
{0} {1} @. {2}", DateTime.Now.DayOfW, DateTime.Now.ToLongDateString(),
DateTime.Now.ToLongTimeString()));
sw.WriteLine(String.Format("IP Address: {0}",
Request.ServerVariables["REMOTE_ADDR"].ToString()));
sw.WriteLine(String.Format("Platform: {0}",
Request.Browser.Platform));
sw.WriteLine(String.Format("Browser: {0}",
Request.Browser.Type));
sw.WriteLine(String.Format("Error in: {0}",
Request.Url.ToString()));
sw.WriteLine(String.Format("Error Message: {0}",
objError.Message.ToString()));
sw.WriteLine("Stack Trace:");
sw.WriteLine(objError.StackTrace.ToString());
sw.WriteLine(Environment.NewLine);
sw.WriteLine("---
--");
sw.Close();
}
}
catch
{
//Do something....
}
}
You may also want to look at:
http://support.microsoft.com/defaul...kb;en-us;306355
Hope it helps
Med
"Smith" <Smith@.pricateemail.com> wrote in message
news:e5iA$HRMIHA.1208@.TK2MSFTNGP05.phx.gbl...
> "Med" <nospam@.nowhere.nowhere> wrote in message
> news:%236KXucQMIHA.4228@.TK2MSFTNGP02.phx.gbl...
> The user asp.net process is running under har full permission in the
> folder where the code lives.Also note that the modified date of the error
> file actually change according to the time error occured. It this was
> permission problem, would it be allowed to actually open the file?
> How does ServerClear() helps here?
> Thanks
> S
>
I use the same log class as in the project :
http://www.asp.net/downloads/starter-kits/my-web-pages/
// ========================================
==================================
=====================
//
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Permissive License.
// See
http://www.microsoft.com/resources/...br />
es.mspx.
// All other rights reserved.
//
// ========================================
==================================
=====================
using System;
using System.Web;
using System.Collections.Generic;
using System.Collections.Specialized;
namespace MyWebPagesStarterKit
{
/// <summary>
/// Utility for writing error messages to a Logfile
/// </summary>
[Serializable]
public class Log : Persistable<Log.LogData>
{
/// <summary>
/// Load Log File from App_Data
/// </summary>
public Log()
{
try
{
LoadData();
}
catch { }
}
/// <summary>
/// List of all Log-Entries in the Logfile
/// </summary>
public List<LogData.LogEntry> Entries
{
get { return _data.LogEntries; }
}
/// <summary>
/// Adding a new Log-Entry to the LogData
/// </summary>
/// <param name="Created"></param>
/// <param name="PageTitle"></param>
public void AddLogEntry(HttpRequest httpRequest, Exception ex)
{
LogData.LogEntry entry = new LogData.LogEntry();
//PageTitle
entry.PageTitle = httpRequest.Url.AbsolutePath;
//Date
entry.Created = DateTime.Now.ToLongDateString() + " " +
DateTime.Now.ToLongTimeString();
//Error
entry.Error = ex.ToString();
//HTTP-Values
foreach (string key in httpRequest.ServerVariables)
{
string value = httpRequest.ServerVariables[key];
if (value != string.Empty)
{
if (key == "ALL_HTTP" || key == "ALL_RAW")
value = value.Replace(System.Environment.NewLine, ", ");
entry.ServerVariables.Add(key + ": " + value);
}
}
/ ========================================
===================================
====================
//
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Permissive License.
// See
http://www.microsoft.com/resources/...br />
es.mspx.
// All other rights reserved.
//
// ========================================
==================================
=====================
using System;
using System.Web;
using System.IO;
using System.Xml.Serialization;
using System.Web.Caching;
namespace MyWebPagesStarterKit
{
/// <summary>
/// Generic class for a perssitable object. Encapsulates the logic to
load/save data from/to the filesystem. To speed up the acces, caching is
used.
/// </summary>
/// <typeparam name="T">class or struct with all the data-fields that must
be persisted</typeparam>
public abstract class Persistable<T>
{
private String _path;
protected T _data;
/// <summary>
/// Creates a instance of Persistable. Also creates a instance of T
/// </summary>
public Persistable()
{
_data = (T)Activator.CreateInstance(typeof(T));
}
/// <summary>
/// Loads the data from the filesystem. For deserialization a XmlSeralizer
is used.
/// </summary>
protected void LoadData()
{
_path = HttpContext.Current.Server.MapPath(GetDataFilename());
lock (_path)
{
//first check, if the object is maybe already in the cache
object o = HttpContext.Current.Cache[_path];
if (o != null)
{
_data = (T)o;
}
else
{
//if nothing was found in the cache, the data must be loaded from the disk
//load and deserialize the data from the filesystem
using (FileStream reader = File.Open(_path, FileMode.Open, FileAccess.Read,
FileShare.ReadWrite))
{
XmlSerializer serializer = new XmlSerializer(typeof(T));
_data = (T)serializer.Deserialize(reader);
}
HttpContext.Current.Cache.Insert(_path, _data);
}
}
}
/// <summary>
/// Persists the data back to the filesystem
/// </summary>
public void SaveData()
{
_path = HttpContext.Current.Server.MapPath(GetDataFilename());
lock (_path)
{
//insert the data into the cache
HttpContext.Current.Cache.Insert(_path, _data, null, DateTime.MaxValue,
TimeSpan.FromHours(1), CacheItemPriority.Normal, null);
//if the given path does not exist yet, create it
if (!Directory.Exists(Path.GetDirectoryName(_path)))
Directory.CreateDirectory(Path.GetDirectoryName(_path));
//serialize and store the data to the filesystem
using (FileStream writer = File.Create(_path))
{
XmlSerializer serializer = new XmlSerializer(typeof(T));
serializer.Serialize(writer, _data);
}
}
}
//Deletes the data from the cache and filesystem
public virtual bool Delete()
{
bool success = true;
if (File.Exists(_path))
{
lock (_path)
{
try
{
File.Delete(_path);
HttpContext.Current.Cache.Remove(_path);
}
catch { success = false; }
}
}
return success;
}
protected abstract string GetDataFilename();
}
}
Cheers
S

Strange compilation error

Hi,

From time to time, I receive following error message when trying to access
my website.
When the error occurs, I have to recompile my dll until the error disappears
(this without changing anything in my code).
Where does this error come from ? What can I do to solve the problem ?
Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: CS0030: Cannot convert type
'System.Web.HttpApplication' to 'ASP.Global_asax'

Source Error:

Line 438: protected ASP.Global_asax ApplicationInstance {
Line 439: get {
Line 440: return
((ASP.Global_asax)(this.Context.ApplicationInstanc e));
Line 441: }
Line 442: }

Source File: c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Tempo rary ASP.NET
Files\emagic.net.website\1a713704\55d0ac6a\5rffbzu b.0.cs Line: 440Hi,

As you can figure out its a prpblem with dynamic compilation of pages
(and asax). do you write any code in your application asax file? if so
can you post it or at least tell what you are doing ? usually those
errors ate outcome of code being write in asax code behind.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Strange compilation error

Hi,
From time to time, I receive following error message when trying to access
my website.
When the error occurs, I have to recompile my dll until the error disappears
(this without changing anything in my code).
Where does this error come from ? What can I do to solve the problem ?
Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.
Compiler Error Message: CS0030: Cannot convert type
'System.Web.HttpApplication' to 'ASP.Global_asax'
Source Error:
Line 438: protected ASP.Global_asax ApplicationInstance {
Line 439: get {
Line 440: return
((ASP.Global_asax)(this.Context.ApplicationInstance));
Line 441: }
Line 442: }
Source File: c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET
Files\emagic.net.website\1a713704\55d0ac6a\5rffbzub.0.cs Line: 440Hi,
As you can figure out its a prpblem with dynamic compilation of pages
(and asax). do you write any code in your application asax file? if so
can you post it or at least tell what you are doing ? usually those
errors ate outcome of code being write in asax code behind.
Natty Gur[MVP]
blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!

Monday, March 26, 2012

Strange DateDiff result

Hi

Can anyone tell me why I get a date difference of 0 for the following code? I was expecting 1.

The code:

strDateDif = Ctype(DateDiff("d", dtItem, dtToday), String)
Response.Write("DateDif between " & dtItem & " and " & dtToday & " = " & strDateDif & "<br />")

The result:

DateDif between 27/02/2006 09:42:43 and 28/02/2006 08:57:16 = 0

Many thanks

Shaun

Hi Shaun,

It is less then a day difference


Ah, so a 'day' ago is at least 24 hrs ago rather than simply yesterday? Makes sense.

If so, is there a way to distinguish between today and yesterday?

My script retrieves website hits for each day that has received at least one hit in the last 7 days. This means the SQL may not pass data for all 7 days. Only those days that have at least one hit.

This data is shown on a graph. To create each bar of the graph, I set the height of one of the images; imgDay0, imgDay1, imgDay2, imgDay3, imgDay4, imgDay5, imgDay6.

I have the HitDate and HitNumber as a par in a HashTable.

For each item in the HashTable, I need to set the height of the bar image on the graph corresponding to the date.

To do this, I use the DateDiff to work out the name of the image we are targeting.

If the DateDiff is 0, we're targeting img0, if the DateDiff is 1, we target img1 etc. My code is below:

For Each objItem in statsHashTable
dtItem = objItem.Key
intStat = objItem.Value
strDateDif = Ctype(DateDiff("d", dtItem, Now()), String)
Response.Write("DateDif between " & dtItem & " and " & dtToday & " = " & strDateDif & "<br />")

imgDayName = "imgDay" & strDateDif
imgDay = FindControl(imgDayName)

intPercentage = (intStat/intHighNumber) * 100
intBarHeight = Math.Round((intGraphHeight/100) * intPercentage)

imgDay.Height = Unit.Pixel(intBarHeight)
imgDay.ToolTip = CType(intStat, String)

Next

Is there another way to ensure that if the date we are using is 'yesterday', we get a DateDiff of 1? Should I be using something other than "d" in my DateDiff?

Many thanks

Shaun


Thetime is also taken into consideration in the DateDiff function. as you can see the the difference isless that one day when the time is also considered. So it is returning as 0.

If needed you can format the date to dd/mm/yyyy format without the time to get the desired result

Regards


Hi,

You can compare dtItem.Day with Now().Day instead of using DateDiff.


Brilliant. Yes, both of these options work.

I have opted for the first. I simply format the dates like so:

myDate.ToString("D") before using DateDiff. This strips out the time and leaves just the date, which then gives me the desired answer.

Many thanks for your help.

Shaun

Strange download problem!

Hi! everybody,

I'm facing a quite strange download problem. I use the following code to
download an XML file to client side:

With Response
' clear buffer
Call .Clear()

' specify the type of the downloadable file
.ContentType = "application/octet-stream" ' I have
also tried to change this statement to Response.ContentType = "Text/XML"
, but the result is same

' det the default filename in the FileDownload dialog box
Call .AddHeader("Content-Disposition", "attachment;
filename=""Download.XML""")

' force to flush buffer
Call .Flush()

' download the file
Call .WriteFile("Original.XML")
End With

When the download is finished, I found that some HTML code are attached to
the end of my original XML statements in download file. The HTML code is
what exact the form just before download. I would like to know what causes
this result and the solution. Certainly, I need the XML content only.

Thanks for your attention and kindly advice!

Regards,
JamesOne suggestion, try Response.Write(file) instead of writefile, that may cure
the ailment.

--

----
Got TidBits?
Get it here: www.networkip.net/tidbits
"James Wong" <cp_msdn@.commercialpress.com.hk.NO_SPAM> wrote in message
news:ezSMNkYrDHA.2600@.TK2MSFTNGP09.phx.gbl...
> Hi! everybody,
> I'm facing a quite strange download problem. I use the following code to
> download an XML file to client side:
> With Response
> ' clear buffer
> Call .Clear()
> ' specify the type of the downloadable file
> .ContentType = "application/octet-stream" ' I have
> also tried to change this statement to Response.ContentType = "Text/XML"
> , but the result is same
> ' det the default filename in the FileDownload dialog box
> Call .AddHeader("Content-Disposition", "attachment;
> filename=""Download.XML""")
> ' force to flush buffer
> Call .Flush()
> ' download the file
> Call .WriteFile("Original.XML")
> End With
> When the download is finished, I found that some HTML code are attached to
> the end of my original XML statements in download file. The HTML code is
> what exact the form just before download. I would like to know what
causes
> this result and the solution. Certainly, I need the XML content only.
> Thanks for your attention and kindly advice!
> Regards,
> James
Alvin,

Thanks for your response. But even I change it to Response.Write, the
strange behavior still be there.

Regards,
James

"Alvin Bruney" <vapordan_spam_me_not@.hotmail_no_spamhotmail.com> bl
news:ebZTV6YrDHA.2416@.TK2MSFTNGP10.phx.gbl g...
> One suggestion, try Response.Write(file) instead of writefile, that may
cure
> the ailment.
Hello James,

Thanks for posting in the group.

Please try adding Call.End() before "End With" to see if it works.

I used the following code and it works great for me:

string filename = "C:\MyFolder\MyFile.xml";
System.IO.FileInfo file = new System.IO.FileInfo(fileName);
Response.Clear(); // clear the current output content from the buffer
Response.AppendHeader("Content-Disposition", "attachment; filename=" +
file.Name);
Response.AppendHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(file.FullName);
Response.End();

Does that answer your question? If the problem is still there, please feel
free to post here.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
After call Call .WriteFile("Original.XML") type
Response.End();
Will work.

Thanks,

sswalia
MCSD, MCAD, OCA

"James Wong" <cp_msdn@.commercialpress.com.hk.NO_SPAM> wrote in message
news:ezSMNkYrDHA.2600@.TK2MSFTNGP09.phx.gbl...
> Hi! everybody,
> I'm facing a quite strange download problem. I use the following code to
> download an XML file to client side:
> With Response
> ' clear buffer
> Call .Clear()
> ' specify the type of the downloadable file
> .ContentType = "application/octet-stream" ' I have
> also tried to change this statement to Response.ContentType = "Text/XML"
> , but the result is same
> ' det the default filename in the FileDownload dialog box
> Call .AddHeader("Content-Disposition", "attachment;
> filename=""Download.XML""")
> ' force to flush buffer
> Call .Flush()
> ' download the file
> Call .WriteFile("Original.XML")
> End With
> When the download is finished, I found that some HTML code are attached to
> the end of my original XML statements in download file. The HTML code is
> what exact the form just before download. I would like to know what
causes
> this result and the solution. Certainly, I need the XML content only.
> Thanks for your attention and kindly advice!
> Regards,
> James
Hi! Yanhong and SSW,

Thanks for your reply! I works by adding Call .End() and solve my problem.

However, there is a side-effect by doing so. Threading.ThreadAbortException
is fired once the .End() method is called. My workround is to handle this
exception and put all remaining statements after the .End() method under
this exception handling routine. Do you have a better idea to overcome this
side-effect?

Anyway, thanks for your effort!

Regards,
James

"Yan-Hong Huang[MSFT]" <yhhuang@.online.microsoft.com> bl
news:PFz0azZrDHA.1544@.cpmsftngxa06.phx.gbl g...
> Hello James,
> Thanks for posting in the group.
> Please try adding Call.End() before "End With" to see if it works.
> I used the following code and it works great for me:
> string filename = "C:\MyFolder\MyFile.xml";
> System.IO.FileInfo file = new System.IO.FileInfo(fileName);
> Response.Clear(); // clear the current output content from the buffer
> Response.AppendHeader("Content-Disposition", "attachment; filename=" +
> file.Name);
> Response.AppendHeader("Content-Length", file.Length.ToString());
> Response.ContentType = "application/octet-stream";
> Response.WriteFile(file.FullName);
> Response.End();
> Does that answer your question? If the problem is still there, please feel
> free to post here.
> Best regards,
> Yanhong Huang
> Microsoft Online Partner Support
> Get Secure! C www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no
rights.
Hello

Put the remaining state after the .End() statement. The .NET Framework will
handle the ThreadAbortException

Best regards
Sherif

"James Wong" <cp_msdn@.commercialpress.com.hk.NO_SPAM> wrote in message
news:#mepTgarDHA.1488@.TK2MSFTNGP12.phx.gbl...
> Hi! Yanhong and SSW,
> Thanks for your reply! I works by adding Call .End() and solve my
problem.
> However, there is a side-effect by doing so.
Threading.ThreadAbortException
> is fired once the .End() method is called. My workround is to handle this
> exception and put all remaining statements after the .End() method under
> this exception handling routine. Do you have a better idea to overcome
this
> side-effect?
> Anyway, thanks for your effort!
> Regards,
> James
> "Yan-Hong Huang[MSFT]" <yhhuang@.online.microsoft.com> bl
> news:PFz0azZrDHA.1544@.cpmsftngxa06.phx.gbl g...
> > Hello James,
> > Thanks for posting in the group.
> > Please try adding Call.End() before "End With" to see if it works.
> > I used the following code and it works great for me:
> > string filename = "C:\MyFolder\MyFile.xml";
> > System.IO.FileInfo file = new System.IO.FileInfo(fileName);
> > Response.Clear(); // clear the current output content from the buffer
> > Response.AppendHeader("Content-Disposition", "attachment; filename=" +
> > file.Name);
> > Response.AppendHeader("Content-Length", file.Length.ToString());
> > Response.ContentType = "application/octet-stream";
> > Response.WriteFile(file.FullName);
> > Response.End();
> > Does that answer your question? If the problem is still there, please
feel
> > free to post here.
> > Best regards,
> > Yanhong Huang
> > Microsoft Online Partner Support
> > Get Secure! C www.microsoft.com/security
> > This posting is provided "AS IS" with no warranties, and confers no
> rights.
Hello, Sherif,

I have my own exceptional handler which handles all unexpected exceptions.
So if I don't handle it, this exception will fire my default exceptional
handling routine which logs exception details in my self-defined log and
also sends an e-mail to me. That's why I have to handle it. Do you think
there is other better workaround?

Regards,
James

"Sherif ElMetainy" <elmeteny.NOSPAM@.wayout.net.NOSPAM> bl
news:es0vEfbrDHA.1408@.TK2MSFTNGP11.phx.gbl g...
> Hello
> Put the remaining state after the .End() statement. The .NET Framework
will
> handle the ThreadAbortException
> Best regards
> Sherif
> "James Wong" <cp_msdn@.commercialpress.com.hk.NO_SPAM> wrote in message
> news:#mepTgarDHA.1488@.TK2MSFTNGP12.phx.gbl...
> > Hi! Yanhong and SSW,
> > Thanks for your reply! I works by adding Call .End() and solve my
> problem.
> > However, there is a side-effect by doing so.
> Threading.ThreadAbortException
> > is fired once the .End() method is called. My workround is to handle
this
> > exception and put all remaining statements after the .End() method under
> > this exception handling routine. Do you have a better idea to overcome
> this
> > side-effect?
> > Anyway, thanks for your effort!
> > Regards,
> > James
> > "Yan-Hong Huang[MSFT]" <yhhuang@.online.microsoft.com> bl
> > news:PFz0azZrDHA.1544@.cpmsftngxa06.phx.gbl g...
> > > Hello James,
> > > > Thanks for posting in the group.
> > > > Please try adding Call.End() before "End With" to see if it works.
> > > > I used the following code and it works great for me:
> > > > string filename = "C:\MyFolder\MyFile.xml";
> > > System.IO.FileInfo file = new System.IO.FileInfo(fileName);
> > > Response.Clear(); // clear the current output content from the buffer
> > > Response.AppendHeader("Content-Disposition", "attachment; filename=" +
> > > file.Name);
> > > Response.AppendHeader("Content-Length", file.Length.ToString());
> > > Response.ContentType = "application/octet-stream";
> > > Response.WriteFile(file.FullName);
> > > Response.End();
> > > > Does that answer your question? If the problem is still there, please
> feel
> > > free to post here.
> > > > Best regards,
> > > Yanhong Huang
> > > Microsoft Online Partner Support
> > > > Get Secure! C www.microsoft.com/security
> > > This posting is provided "AS IS" with no warranties, and confers no
> > rights.
>
Hello

ThreadAbortException is special in that even if your handler catches it, it
will be rethrown again at the end of the catch block, unless you call
Thread.ResetAbort(). In your case it is not appropriate to call
ResetAbort(), because this means the rendering of the page will continue.
If you don't want to call Response.End() which throws the
ThreadAbortException, you can override the Render Method and not call the
base class Render method.

Best regards
Sherif

"James Wong" <cp_msdn@.commercialpress.com.hk.NO_SPAM> wrote in message
news:eJqBmzbrDHA.3732@.tk2msftngp13.phx.gbl...
> Hello, Sherif,
> I have my own exceptional handler which handles all unexpected exceptions.
> So if I don't handle it, this exception will fire my default exceptional
> handling routine which logs exception details in my self-defined log and
> also sends an e-mail to me. That's why I have to handle it. Do you think
> there is other better workaround?
> Regards,
> James
> "Sherif ElMetainy" <elmeteny.NOSPAM@.wayout.net.NOSPAM> bl
> news:es0vEfbrDHA.1408@.TK2MSFTNGP11.phx.gbl g...
> > Hello
> > Put the remaining state after the .End() statement. The .NET Framework
> will
> > handle the ThreadAbortException
> > Best regards
> > Sherif
> > "James Wong" <cp_msdn@.commercialpress.com.hk.NO_SPAM> wrote in message
> > news:#mepTgarDHA.1488@.TK2MSFTNGP12.phx.gbl...
> > > Hi! Yanhong and SSW,
> > > > Thanks for your reply! I works by adding Call .End() and solve my
> > problem.
> > > > However, there is a side-effect by doing so.
> > Threading.ThreadAbortException
> > > is fired once the .End() method is called. My workround is to handle
> this
> > > exception and put all remaining statements after the .End() method
under
> > > this exception handling routine. Do you have a better idea to
overcome
> > this
> > > side-effect?
> > > > Anyway, thanks for your effort!
> > > > Regards,
> > > James
> > > > "Yan-Hong Huang[MSFT]" <yhhuang@.online.microsoft.com> bl
> > > news:PFz0azZrDHA.1544@.cpmsftngxa06.phx.gbl g...
> > > > Hello James,
> > > > > > Thanks for posting in the group.
> > > > > > Please try adding Call.End() before "End With" to see if it works.
> > > > > > I used the following code and it works great for me:
> > > > > > string filename = "C:\MyFolder\MyFile.xml";
> > > > System.IO.FileInfo file = new System.IO.FileInfo(fileName);
> > > > Response.Clear(); // clear the current output content from the
buffer
> > > > Response.AppendHeader("Content-Disposition", "attachment; filename="
+
> > > > file.Name);
> > > > Response.AppendHeader("Content-Length", file.Length.ToString());
> > > > Response.ContentType = "application/octet-stream";
> > > > Response.WriteFile(file.FullName);
> > > > Response.End();
> > > > > > Does that answer your question? If the problem is still there,
please
> > feel
> > > > free to post here.
> > > > > > Best regards,
> > > > Yanhong Huang
> > > > Microsoft Online Partner Support
> > > > > > Get Secure! C www.microsoft.com/security
> > > > This posting is provided "AS IS" with no warranties, and confers no
> > > rights.
> > > >
Hello James,

Thanks for your response.

The Response.End method ends the page execution and shifts the execution to
the Application_EndRequest event in the application's event pipeline. The
line of code that follows Response.End is not executed. So
ThreadAbortException exception occurs.

To work around this problem, For Response.End, call the
ApplicationInstance.CompleteRequest method instead of Response.End to
bypass the code execution to the Application_EndRequest event.

For detailed info on it, please refer to MSDN article:
"PRB: ThreadAbortException Occurs If You Use Response.End,
Response.Redirect, or Server.Transfer"
http://support.microsoft.com/?id=312629

Does that answer your questoin?

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Hello Yan-Hong,

Thanks for you reply again!

I think this is a quite interesting case since when I use
ApplicationInstance.CompleteRequest instead of Response.End, no more
exception is captured. However, the original problem, HTML codes are
included in the downloaded file, comes again!

Until now, I think using Reponse.End with additional exceptional handler (in
which the remaining codes after Response.End are there) may be the best way
to solve my problem.

If you have any other good idea, please let me know and share with all
others here.

Regards,
James

"Yan-Hong Huang[MSFT]" <yhhuang@.online.microsoft.com> bl
news:Yxq4fBlrDHA.1212@.cpmsftngxa06.phx.gbl g...
> Hello James,
> Thanks for your response.
> The Response.End method ends the page execution and shifts the execution
to
> the Application_EndRequest event in the application's event pipeline. The
> line of code that follows Response.End is not executed. So
> ThreadAbortException exception occurs.
> To work around this problem, For Response.End, call the
> ApplicationInstance.CompleteRequest method instead of Response.End to
> bypass the code execution to the Application_EndRequest event.
> For detailed info on it, please refer to MSDN article:
> "PRB: ThreadAbortException Occurs If You Use Response.End,
> Response.Redirect, or Server.Transfer"
> http://support.microsoft.com/?id=312629
> Does that answer your questoin?
> Best regards,
> Yanhong Huang
> Microsoft Online Partner Support
> Get Secure! C www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no
rights.
Hello Sherif,

Thanks again for your reply!

Do you mean that I should put all remaining codes outside the
Try...Catch...End Try block? On the other hand, I don't understand what
class's Render method you suggest me to override.

Regards,
James

"Sherif ElMetainy" <elmeteny.NOSPAM@.wayout.net.NOSPAM> bl
news:OOAFiVcrDHA.2304@.TK2MSFTNGP11.phx.gbl g...
> Hello
> ThreadAbortException is special in that even if your handler catches it,
it
> will be rethrown again at the end of the catch block, unless you call
> Thread.ResetAbort(). In your case it is not appropriate to call
> ResetAbort(), because this means the rendering of the page will continue.
> If you don't want to call Response.End() which throws the
> ThreadAbortException, you can override the Render Method and not call the
> base class Render method.
> Best regards
> Sherif
Hi James,

Just now I found this good article for you. :)

It contains a good sample in ASP.NET on how to download and upload file.

"Downloading and Uploading Files"
http://msdn.microsoft.com/library/e...pmig-downloadin
ganduploading.asp?frame=true#aspnet-jspmig-downloadinganduploading_topic6

Hope that helps.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Yan-Hong,

Thanks again for your effort on my problem. I'll study the document to
solve my problem.

Regards,
James

"Yan-Hong Huang[MSFT]" <yhhuang@.online.microsoft.com> bl
news:CjFnTunrDHA.1716@.cpmsftngxa06.phx.gbl g...
> Hi James,
> Just now I found this good article for you. :)
> It contains a good sample in ASP.NET on how to download and upload file.
> "Downloading and Uploading Files"
http://msdn.microsoft.com/library/e...pmig-downloadin
> ganduploading.asp?frame=true#aspnet-jspmig-downloadinganduploading_topic6
> Hope that helps.
> Best regards,
> Yanhong Huang
> Microsoft Online Partner Support
> Get Secure! C www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no
rights.
Hi James,

It is my pleasure. :)

Thanks very much for participating the community.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Strange Error

Hello,

I am using ASP.NET 2.0 with SQL 2005 to save the profile.

Suddenly, out of nothing I got the following error:

The 'System.Web.Profile.SqlProfileProvider' requires adatabase schema compatible with schema version '1'. However, thecurrent database schema is not compatible with this version. You mayneed to either install a compatible schema with aspnet_regsql.exe(available in the framework installation directory), or upgrade theprovider to a newer version.

Description:Anunhandled exception occurred during the execution of the current webrequest. Please review the stack trace for more information about theerror and where it originated in the code.

Exception Details:System.Configuration.Provider.ProviderException:The 'System.Web.Profile.SqlProfileProvider' requires a database schemacompatible with schema version '1'. However, the current databaseschema is not compatible with this version. You may need to eitherinstall a compatible schema with aspnet_regsql.exe (available in theframework installation directory), or upgrade the provider to a newerversion.

Source Error:

Line 22: Public Overridable Property Contacts() As PR.Contacts
Line 23: Get
Line 24: Return CType(Me.GetPropertyValue("Contacts"),PR.Contacts)
Line 25: End Get
Line 26: Set


I have no idea what is going on.

I already deleted all the databases and added a few more but nothing ... I used aspnet_regsql.exe from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe.

What should I do?

Thanks,

Miguel

You are missing the schema entry in the aspnet_schemaversions table for your database, if you moved the db from one server to another using scripts you still need to add the entries in this table.

Open this table and see if anything is missing. (profile,1,true) is what you need.

-c


Hello,

I didn't move the database. This is on my computer and I created the databases using aspnet_regsql.exe.

I opened ScemaVersions database and I have this:

common1Truehealth monitoring1Truemembership1Truepersonalization1Trueprofile1Truerole manager1True

What might be going wrong here?

I started to get this error out of nothing. I really have no idea what might be the cause of it.

Thanks,

Miguel


Can you post the profile config xml from your web.config - remember to hide passwords! ;)

Hi,

Where is my profile code in Web.Config:

<!-- Profile -->
<profile enabled="true" defaultProvider="ProfileProvider" automaticSaveEnabled="true">

<!-- Profile Providers -->
<providers>
<clear/>
<add applicationName="AppName" connectionStringName="MyDatabase" name="ProfileProvider" type="System.Web.Profile.SqlProfileProvider"/>
</providers>

<!-- Profile Properties -->
<properties>
<add allowAnonymous="false" name="Collaborator" type="MyWebSite.Collaborator" serializeAs="Binary"/>
<add allowAnonymous="false" name="Contacts" type="MyWebSite.Contacts" serializeAs="Binary"/>
<add allowAnonymous="false" name="Options" type="MyWebSite.Options" serializeAs="Binary"/>
<add allowAnonymous="false" name="Personal" type="MyWebSite.Personal" serializeAs="Binary"/>
<add allowAnonymous="true" name="Settings" type="MyWebSite.Settings" serializeAs="Binary"/>
</properties>

</profile>

Any idea what might be going on?

Thanks,

Miguel


Ok some more questions - I see you're using custom types with a binary serializer - why? and did you change the class definitions for any of these custom types? If so and there was stored profile data, this would break your system since the serializer wouldn't be able to de-serialize the objects.

-c


maybe just something to try - but if you did change your class definitions - try deleting all the data in the profile table, it should re-serialize and might fix it.

-c


Hi,

Should I use other type?

Here is a class as example:

' Collaborator
<Serializable()> _
Public Class Collaborator

' -- [Properties] --------------

' Comments
Private _Comments As String
Public Property Comments() As String
Get
Return _Comments
End Get
Set(ByVal value As String)
_Comments = value
End Set
End Property ' Comments

' CurriculumVitae
Private _CurriculumVitae As String
Public Property CurriculumVitae() As String
Get
Return _CurriculumVitae
End Get
Set(ByVal value As String)
_CurriculumVitae = value
End Set
End Property ' CurriculumVitae
...

And by the way, suddenly I stopped getting the error.

This was really strange.

Thanks,

Miguel

strange ERROR

Hi..

Can any one tell me what is the following error mean and what is its reason?

Error 1 Validation (ASP.Net): Text is not allowed between the opening and closing tags for element MultiView'.

Please help me because it is appear to me in many pages.

Thanks..

The<asp:MultiView> control is a container for a group of<asp:View> controls. insert your contents in MultiView using <asp:View>

<asp:MultiView id="value" Runat="Server" ActiveViewIndex="viewindex"
<asp:View id="value1" Runat="Server"

...insert yourControls, text, and HTML

</asp:View>

<asp:View id="value2" Runat="Server"

...insert yourControls, text, and HTML

</asp:View>
...

</asp:MultiView>


I do exactly what you say but the error is not removeCrying


Please post the block of code pointed to by this error.


Hi..

This is the code:

<%@.PageLanguage="C#"MasterPageFile="~/Administration/AdministrationMasterPage.master"AutoEventWireup="true"CodeFile="UpdateStudentPayment.aspx.cs"Inherits="Administration_UpdateStudentPayment"Title="???????????????????????????"%><asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server"> <divalign=center> <asp:ScriptManagerid="ScriptManager1"runat="server"> </asp:ScriptManager> <br/> <asp:UpdatePanelid="UpdatePanel1"runat="server"UpdateMode="Conditional"> <contenttemplate><asp:MultiViewID="MultiView1"runat="server">//Here is the error <asp:Viewid="View1"runat="server"> <strong><spanstyle="font-size: 24pt"><spanstyle="font-size: 20pt; color: #228b22"></span></span></strong> <asp:LabelID="Label14"runat="server"Text="Label"></asp:Label><br/> <br/> <SPANstyle="COLOR: red"><SPANstyle="FONT-SIZE: 24pt; COLOR: #228b22"></SPAN> <asp:Labelid="Label1"runat="server"Text="?????????:"ForeColor="ForestGreen"Font-Bold="True"></asp:Label> <asp:TextBoxid="TextBox1"runat="server"></asp:TextBox> <BR/> <asp:RegularExpressionValidatorid="RegularExpressionValidator2"runat="server"Font-Bold="True"ValidationExpression="^\d*"ErrorMessage="?????????????????????????? ..."ControlToValidate="TextBox1"></asp:RegularExpressionValidator><BR/> <asp:Labelid="Label9"runat="server"Text="Label"ForeColor="Red"Font-Bold="True"></asp:Label><br/> <BR/><asp:Buttonid="Button1"onclick="Button1_Click1"runat="server"ToolTip="????????????"Width="105px"Text="??????????"ForeColor="ForestGreen"Font-Bold="False"Font-Size="Large"></asp:Button><BR/><BR/> <asp:DetailsViewid="DetailsView1"runat="server"Width="460px"Height="50px"ForeColor="#333333"Font-Bold="True"OnLoad="DetailsView1_Load"OnDataBound="DetailsView1_DataBound"OnDataBinding="DetailsView1_DataBinding"GridLines="None"DataSourceID="SqlDataSource1"DataKeyNames="StudentPaymentID"CellPadding="4"AutoGenerateRows="False"> <FooterStyleBackColor="#507CD1"ForeColor="White"Font-Bold="True"></FooterStyle> <CommandRowStyleBackColor="#D1DDF1"Font-Bold="True"></CommandRowStyle> <EditRowStyleBackColor="#2461BF"></EditRowStyle> <RowStyleBackColor="#D8F3D0"CssClass="leftToRight"></RowStyle> <PagerStyleBackColor="#2461BF"ForeColor="White"HorizontalAlign="Center"></PagerStyle> <Fields> <asp:BoundFieldDataField="StudentPayment_UserID"SortExpression="StudentPayment_UserID"HeaderText="?????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="UserName"SortExpression="UserName"HeaderText="?????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldReadOnly="True"DataField="StudentPaymentID"InsertVisible="False"SortExpression="StudentPaymentID"HeaderText="????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="TotalPrice"SortExpression="TotalPrice"HeaderText="?????????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="PaidMoney"SortExpression="PaidMoney"HeaderText="?????????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="ReminderMoney"SortExpression="ReminderMoney"HeaderText="????????????? "> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="PaymentDtae"SortExpression="PaymentDtae"HeaderText="?????????? "> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> </Fields> <FieldHeaderStyleBackColor="#C5E9B9"Font-Bold="True"></FieldHeaderStyle> <HeaderStyleBackColor="#507CD1"ForeColor="White"Font-Bold="True"></HeaderStyle> <AlternatingRowStyleBackColor="White"></AlternatingRowStyle> </asp:DetailsView> <asp:SqlDataSourceid="SqlDataSource1"runat="server"SelectCommand="SELECT StudentPayment.*, users.UserName, StudentPayment.StudentPayment_UserID AS Expr1 FROM StudentPayment INNER JOIN users ON StudentPayment.StudentPayment_UserID = users.UserID WHERE (StudentPayment.StudentPayment_UserID = @.UserID)"ConnectionString="<%$ ConnectionStrings:dbconn%>"> <SelectParameters> <asp:ControlParameterControlID="TextBox1"Name="UserID"PropertyName="Text"/> </SelectParameters> </asp:SqlDataSource><BR/><asp:Labelid="Label3"runat="server"Text="?????????????????????????"ForeColor="Red"Font-Bold="True"></asp:Label> <asp:Labelid="Label7"runat="server"Text="Label"ForeColor="Red"Font-Bold="True"></asp:Label> <asp:Labelid="Label4"runat="server"Text="Label"ForeColor="Red"Font-Bold="True"></asp:Label> <asp:Labelid="Label11"runat="server"Text="Label"ForeColor="Red"Font-Bold="True"></asp:Label><BR/><BR/> <asp:Labelid="Label2"runat="server"Text="?????????????????????????? :"ForeColor="ForestGreen"Font-Bold="True"></asp:Label> <asp:TextBoxid="TextBox2"runat="server"OnTextChanged="TextBox2_TextChanged"></asp:TextBox><BR/><BR/> <asp:RegularExpressionValidatorid="RegularExpressionValidator3"runat="server"Font-Bold="True"ValidationExpression="^\d*"ErrorMessage="?????????????????????????? ..."ControlToValidate="TextBox2"></asp:RegularExpressionValidator><BR/><BR/> <asp:Labelid="Label12"runat="server"Text="Label"Font-Bold="True"></asp:Label><BR/><BR/> <asp:Buttonid="Button2"onclick="Button2_Click"runat="server"ToolTip="????????????"Width="75px"Text="????????????"ForeColor="ForestGreen"Font-Size="Large"></asp:Button> <asp:Buttonid="Button3"runat="server"ToolTip="????????????"Width="81px"Text="????????????"ForeColor="ForestGreen"Font-Size="Large"PostBackUrl="~/Administration/Students.aspx"></asp:Button> </SPAN> <STRONG><SPANstyle="FONT-SIZE: 24pt"><BR/></SPAN></STRONG> </asp:View> <asp:Viewid="View2"runat="server"><BR/> <asp:Labelid="Label5"runat="server"Visible="False"Text="????????????????????????"ForeColor="Red"Font-Bold="True"></asp:Label> <SPANstyle="COLOR: red"></SPAN> <asp:Labelid="Label8"runat="server"Text="Label"ForeColor="Red"Font-Bold="True"></asp:Label> <SPANstyle="COLOR: red"></SPAN> <asp:Labelid="Label6"runat="server"Visible="False"Text="Label"ForeColor="Red"Font-Bold="True"></asp:Label> <asp:Labelid="Label10"runat="server"Text="Label"ForeColor="Red"Font-Bold="True"></asp:Label> <SPANstyle="COLOR: red"></SPAN> <SPANstyle="COLOR: forestgreen"><SPANstyle="COLOR: red"></SPAN><BR/></SPAN> <asp:LabelID="Label15"runat="server"Text="?????????????????????????????????? "></asp:Label> <SPANstyle="COLOR: #333333"><BR/></SPAN><BR/> <asp:DetailsViewid="DetailsView2"runat="server"Width="460px"Height="50px"ForeColor="#333333"Font-Bold="True"GridLines="None"DataSourceID="SqlDataSource1"DataKeyNames="StudentPaymentID"CellPadding="4"AutoGenerateRows="False"> <FooterStyleBackColor="#507CD1"ForeColor="White"Font-Bold="True"></FooterStyle> <CommandRowStyleBackColor="#D1DDF1"Font-Bold="True"></CommandRowStyle> <EditRowStyleBackColor="#2461BF"></EditRowStyle> <RowStyleBackColor="#D8F3D0"CssClass="leftToRight"></RowStyle> <PagerStyleBackColor="#2461BF"ForeColor="White"HorizontalAlign="Center"></PagerStyle> <Fields> <asp:BoundFieldDataField="StudentPayment_UserID"SortExpression="StudentPayment_UserID"HeaderText="?????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="UserName"SortExpression="UserName"HeaderText="?????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldReadOnly="True"DataField="StudentPaymentID"InsertVisible="False"SortExpression="StudentPaymentID"HeaderText="????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="TotalPrice"SortExpression="TotalPrice"HeaderText="?????????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="PaidMoney"SortExpression="PaidMoney"HeaderText="?????????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="ReminderMoney"SortExpression="ReminderMoney"HeaderText="?????????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="PaymentDtae"SortExpression="PaymentDtae"HeaderText="??????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> </Fields> <FieldHeaderStyleBackColor="#C5E9B9"Font-Bold="True"></FieldHeaderStyle> <HeaderStyleBackColor="#507CD1"ForeColor="White"Font-Bold="True"></HeaderStyle> <AlternatingRowStyleBackColor="White"></AlternatingRowStyle> </asp:DetailsView><asp:SqlDataSourceid="SqlDataSource2"runat="server"SelectCommand="SELECT StudentPayment.*, users.UserName, StudentPayment.StudentPayment_UserID AS Expr1 FROM StudentPayment INNER JOIN users ON StudentPayment.StudentPayment_UserID = users.UserID WHERE (StudentPayment.StudentPayment_UserID = @.UserID)"ConnectionString="<%$ ConnectionStrings:dbconn%>"> <SelectParameters> <asp:ControlParameterControlID="TextBox1"Name="UserID"PropertyName="Text"/> </SelectParameters> </asp:SqlDataSource><BR/><asp:HyperLinkid="HyperLink1"runat="server"ToolTip="????????????????????? "Font-Bold="True"NavigateUrl="~/Administration/Students.aspx">?????????????????????</asp:HyperLink></asp:View> <BR/> <asp:Viewid="View3"runat="server"><STRONG><SPANstyle="COLOR: #333333"><BR/> <asp:LabelID="Label16"runat="server"Text="??????"></asp:Label> <SPANstyle="COLOR: red"> </SPAN></SPAN></STRONG> <asp:Labelid="Label13"runat="server"Text="Label"ForeColor="Red"Font-Bold="True"></asp:Label> <STRONG><SPANstyle="COLOR: #333333"><SPANstyle="COLOR: red"> <asp:LabelID="Label17"runat="server"Text="????????????????? .."></asp:Label></SPAN><BR/> <asp:DetailsViewid="DetailsView3"runat="server"Width="460px"Height="50px"ForeColor="#333333"Font-Bold="True"GridLines="None"DataSourceID="SqlDataSource3"DataKeyNames="StudentPaymentID"CellPadding="4"AutoGenerateRows="False"> <FooterStyleBackColor="#507CD1"ForeColor="White"Font-Bold="True"></FooterStyle> <CommandRowStyleBackColor="#D1DDF1"Font-Bold="True"></CommandRowStyle> <EditRowStyleBackColor="#2461BF"></EditRowStyle> <RowStyleBackColor="#D8F3D0"CssClass="leftToRight"></RowStyle> <PagerStyleBackColor="#2461BF"ForeColor="White"HorizontalAlign="Center"></PagerStyle> <Fields> <asp:BoundFieldDataField="UserName"SortExpression="UserName"HeaderText="?????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="StudentPayment_UserID"SortExpression="StudentPayment_UserID"HeaderText="?????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="StudentPayment_PaymentID"SortExpression="StudentPayment_PaymentID"HeaderText="????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="TotalPrice"SortExpression="TotalPrice"HeaderText="?????????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="PaidMoney"SortExpression="PaidMoney"HeaderText="?????????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="ReminderMoney"SortExpression="ReminderMoney"HeaderText="?????????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="PaymentDtae"SortExpression="PaymentDtae"HeaderText="??????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> </Fields> <FieldHeaderStyleBackColor="#C5E9B9"Font-Bold="True"></FieldHeaderStyle> <HeaderStyleBackColor="#507CD1"ForeColor="White"Font-Bold="True"></HeaderStyle> <AlternatingRowStyleBackColor="White"></AlternatingRowStyle> </asp:DetailsView> <asp:SqlDataSourceid="SqlDataSource3"runat="server"SelectCommand="SELECT StudentPayment.*, users.UserName, StudentPayment.StudentPayment_UserID AS Expr1 FROM StudentPayment INNER JOIN users ON StudentPayment.StudentPayment_UserID = users.UserID WHERE (StudentPayment.StudentPayment_UserID = @.UserID)"ConnectionString="<%$ ConnectionStrings:dbconn%>"> <SelectParameters> <asp:ControlParameterControlID="TextBox1"Name="UserID"PropertyName="Text"/> </SelectParameters> </asp:SqlDataSource><BR/><asp:HyperLinkid="HyperLink2"runat="server"ToolTip="????????????????????? "NavigateUrl="~/Administration/Students.aspx">?????????????????????</asp:HyperLink><BR/></SPAN></STRONG> </asp:View><BR/> </asp:MultiView></contenttemplate><triggers><asp:AsyncPostBackTriggerControlID="Button1"EventName="Click"></asp:AsyncPostBackTrigger></triggers></asp:UpdatePanel> <br/> <br/> <br/> <br/> <br/> </div></asp:Content>


Sorry for that appearance

Strange Error

I'm getting the following error on when I try to preview webpages from VWD2008. When I upload the pages I can view them fine from my website. Even more stange is it only happens on one certain project and it just started about 10 minutes ago as was fine until then. I have rebooted my computer but that did not help. When I go to view that directory, there are no files in it, nor can I unselect the read-only attribute to delete it.

Compilation Error

Description:An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message:BC30269: 'Public Sub New()' has multiple definitions with identical signatures.

Source Error:

[No relevant source lines]


Source File: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\mysite\1d37002e\e2be952b\App_Code.stpwyaqr.1.vb Line: 34

Can you show us the code behind for one of the pages that you are getting the error?


Weird on a couple of levels; your post does not display correctly to me, the text is all mashed onto a couple of lines. Fortunately the reply screen shows it ok.

I'm not sure I understand so see if this is correct. When you published the project to the web server it worked fine and the site published ok and is browsable. When you then tried to run the project in VWD to preview locally it gave the error you posted. When you went into the file system on your local machine the directory was blank.

Sound correct so far? If so, are you checking the project directory on your local machine or the temporary directory listed in the error message?


Did you try to do a Clean Project and a Rebuild Project? Are you using the Web Site project or Web Application project?


kraznodar:

I'm not sure I understand so see if this is correct. When you published the project to the web server it worked fine and the site published ok and is browsable. When you then tried to run the project in VWD to preview locally it gave the error you posted. When you went into the file system on your local machine the directory was blank.

Yes that is 100% correct. What is even more odd is the fact that I've been working on this same project for about 7 months, and until a while ago I never got this error. When I tried another project on my computer it ran with no errors. As for the page in question it is all the pages, not just one.

Ohhh, I just tried a rebuild like was suggested and got a bunch of errors relating to a dataset file. I deleted the file in question and now it works 100%

I had copied, then pasted a dataset and that must have corrupted something. I deleted it and no problems.

Guess the lesson is, don't copy/paste a dataset like you can a regular webpage file.

Thanks for the help and suggestions, I'm sure I'll have many more :)


Don't forget to mark noahb's post as the answer. His clean and rebuild led to the discovery of the real issue.

strange error - deadlock

HI Y'all,

I get following error and i'm kinda worried:

Transaction (Process ID 194) was deadlocked on lock | communication buffer resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

Anyone ever saw this?

Thanks

Hi,

I saw this sometimes in our environment. What happened is the following: if you have 5 (the number doesn't implicate anything, it could be 2) web applications accessing the same database table at the same time and for some reason one of them is not be able to commit the process, as such all the other applications will be waiting for this process to commit which creates a dead lock in a sense all the applications are waiting for this process and the process it self is waiting to be completed. The only solution in this case is that the database server will stop the deadlock process.

Regards


It appears that the n number of transactions you are using, one of them is blocking operations on the other.
Transactions can be notorious as some of the tend to lock the whole table which is why any other processes trying to access data from that (locked) table it has to wait until the lock is released.

To solve this analyse all the points in your source code which use transactions. Go through each one and make sure the Transaction scope it as small as possible (Small meaning as little work is done there as possible).
This could mean you are declaring variables, doing some complex calculations etc. If you could move all of this outside the scope of the transaction you will end up avoiding this issue. If the transactions are not in the code but in stored proc do the same thing with the SQL scripts. There is a possibility that the table does not have sufficient index, add some indexes to speed up the queries.

Also if SQL Server is being used that would mean there is a possibility that the version you are using has connection limits and hence you app is waiting for a conn to be available, check the documentation of your SQL Server version for this.

Goodluck

Saturday, March 24, 2012

Strange error message

I'm getting the following error from a standard datagrid on an .aspx page, can anyone tell me what causes this?

System.Web.UI.WebControls.DataGridColumnCollection must have items of type 'System.Web.UI.WebControls.DataGridColumn'. 'table' is of type 'System.Web.UI.HtmlControls.HtmlTable'.Can you show how you have declared the DataGrid?
You are propably trying to add a HTML-Table to the Columns-collection of your DataGrid.

If you posted the code where this error occurs we will surely be able to help you out. You can usually find the line-number in the code-behind file from where the error originated. That is if you have compiled in Debug-mode.
I've not included the columns as there's a lot of code, let me know if you need them.


<ASP:DataGrid id="MyDataGrid" runat="server"
Width="500" BorderColor="black"
ShowFooter="false" CellPadding=3 CellSpacing="0"
HeaderStyle-CssClass="scroller" HeaderStyle-BackColor="#000033"
ItemStyle-CssClass="columnText" EditItemStyle-CssClass="columnText"
OnEditCommand="MyDataGrid_Edit" OnCancelCommand="MyDataGrid_Cancel"
OnUpdateCommand="MyDataGrid_Update" OnDeleteCommand="MyDataGrid_Delete"
DataKeyField="SupplierID" AutoGenerateColumns="false"
AllowPaging="true" PageSize="10" OnPageIndexChanged="MyDataGrid_Page"
PagerStyle-Mode="NumericPages" PagerStyle-HorizontalAlign="Right"
PagerStyle-Visible="true" >

Put it all, columns are crucial here.
Here is the full code:


<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
//The line above is the one causing the error
<tr>
<td>
<form id="form1" runat="server">
<table width="590" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<ASP:DataGrid id="MyDataGrid" runat="server"
Width="500" BorderColor="black"
ShowFooter="false" CellPadding=3 CellSpacing="0"
HeaderStyle-CssClass="scroller" HeaderStyle-BackColor="#000033"
ItemStyle-CssClass="columnText" EditItemStyle-CssClass="columnText"
OnEditCommand="MyDataGrid_Edit" OnCancelCommand="MyDataGrid_Cancel"
OnUpdateCommand="MyDataGrid_Update" OnDeleteCommand="MyDataGrid_Delete"
DataKeyField="SupplierID" AutoGenerateColumns="false"
AllowPaging="true" PageSize="10" OnPageIndexChanged="MyDataGrid_Page"
PagerStyle-Mode="NumericPages" PagerStyle-HorizontalAlign="Right"
PagerStyle-Visible="true" >
<Columns>
<asp:EditCommandColumn HeaderText="Edit" EditText="Edit" CancelText="Cancel" UpdateText="Update" ItemStyle-Wrap="false"/>
<asp:BoundColumn HeaderText="ID" SortExpression="SupplierID" ReadOnly="True" DataField="SupplierID" ItemStyle-Wrap="false"/
<asp:TemplateColumn HeaderText="Suppliers" SortExpression="txt_Supplier">
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "txt_Supplier") %>'/>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" id="add_txt_Supplier" Width="150" Text='<%# DataBinder.Eval(Container.DataItem, "txt_Supplier") %>' CssClass="columnText" />
</EditItemTemplate>
</asp:TemplateColumn
<asp:TemplateColumn HeaderText="Contact" SortExpression="txt_Contact">
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "txt_Contact") %>'/>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" id="add_txt_Contact" Width="100" Text='<%# DataBinder.Eval(Container.DataItem, "txt_Contact") %>' CssClass="columnText" />
</EditItemTemplate>
</asp:TemplateColumn
<asp:TemplateColumn HeaderText="Address1" SortExpression="txt_Address1">
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "txt_Address1") %>'/>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" id="add_txt_Address1" Width="150" Text='<%# DataBinder.Eval(Container.DataItem, "txt_Address1") %>' CssClass="columnText" />
</EditItemTemplate>
</asp:TemplateColumn
<asp:TemplateColumn HeaderText="Address2" SortExpression="txt_Address2">
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "txt_Address2") %>'/>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" id="add_txt_Address2" Width="150" Text='<%# DataBinder.Eval(Container.DataItem, "txt_Address2") %>' CssClass="columnText" />
</EditItemTemplate>
</asp:TemplateColumn
<asp:TemplateColumn HeaderText="Town" SortExpression="txt_Town">
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "txt_Town") %>'/>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" id="add_txt_Town" Width="100" Text='<%# DataBinder.Eval(Container.DataItem, "txt_Town") %>' CssClass="columnText" />
</EditItemTemplate>
</asp:TemplateColumn
<asp:TemplateColumn HeaderText="City" SortExpression="txt_City">
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "txt_City") %>'/>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" id="add_txt_City" Width="100" Text='<%# DataBinder.Eval(Container.DataItem, "txt_City") %>' CssClass="columnText" />
</EditItemTemplate>
</asp:TemplateColumn
<asp:TemplateColumn HeaderText="Post Code" SortExpression="txt_PostCode">
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "txt_PostCode") %>'/>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" id="add_txt_PostCode" Width="50" Text='<%# DataBinder.Eval(Container.DataItem, "txt_PostCode") %>' CssClass="columnText" />
</EditItemTemplate>
</asp:TemplateColumn
<asp:TemplateColumn HeaderText="Phone" SortExpression="txt_Phone">
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "txt_Phone") %>'/>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" id="add_txt_Phone" Width="50" Text='<%# DataBinder.Eval(Container.DataItem, "txt_Phone") %>' CssClass="columnText" />
</EditItemTemplate>
</asp:TemplateColumn
<asp:TemplateColumn HeaderText="Fax" SortExpression="txt_Fax">
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "txt_Fax") %>'/>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" id="add_txt_Fax" Width="50" Text='<%# DataBinder.Eval(Container.DataItem, "txt_Fax") %>' CssClass="columnText" />
</EditItemTemplate>
</asp:TemplateColumn
<asp:TemplateColumn HeaderText="Mobile" SortExpression="txt_Mobile">
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "txt_Mobile") %>'/>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" id="add_txt_Mobile" Width="50" Text='<%# DataBinder.Eval(Container.DataItem, "txt_Mobile") %>' CssClass="columnText" />
</EditItemTemplate>
</asp:TemplateColumn
<asp:TemplateColumn HeaderText="Email" SortExpression="txt_Email">
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "txt_Email") %>'/>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" id="add_txt_Email" Width="100" Text='<%# DataBinder.Eval(Container.DataItem, "txt_Email") %>' CssClass="columnText" />
</EditItemTemplate>
</asp:TemplateColumn
<asp:TemplateColumn HeaderText="Notes" SortExpression="txt_SupplierNotes">
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "txt_SupplierNotes") %>'/>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" id="add_txt_SupplierNotes" Width="250" Text='<%# DataBinder.Eval(Container.DataItem, "txt_SupplierNotes") %>'
CssClass="columnText" TextMode="MultiLine" Rows="6"/>
</EditItemTemplate>
</asp:TemplateColumn
</ASP:DataGrid>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>

Are you sure there isn't anything before that line that could cause it? More nested grids or tables?
Nothing that I can see. This is the only datagrid on the page and the other tables on the page are completely seperate from this one.

It's pretty weird as I've created a few other similar pages without any problems.

strange error with array

Dim fontMap(1 to 26, 1 to 10) As Byte

can anyone tell me why i get the following error?
Array declarations cannot specify lower bounds.
thanks: :)

Hi,

Try Dim fontMap(1, 26, 1, 10)AsByte

HTH

Strange Errors

Recently, I copied some files from Development to a testing server. I got the following error.
What is wrong?

Thanks,
Barb

Server Error in '/' Application.
------------------------

Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'test1.LitStoreHome'.

Source Error:

Line 1: <%@dotnet.itags.org. Page Language="vb" trace="true" EnableSessionState="True" AutoEventWireup="false" Codebehind="LitStoreHome.aspx.vb" Inherits="test1.LitStoreHome" %>
Line 2: <HTML>
Line 3: <HEADyou need to copy the /bin dir with required assemblies
or add references to global assemblies in the web.config file
Have you copied the dll from the bin folder.
You guys are absolutely correct, I need to recompile the project or copy dlls.

THANKS!!!