Lets Have a fun with Technology.

BTemplates.com

Follow by Email

Monday, August 10, 2009

Delete Temporary File From ASP.Net


Hello Frd's

There are often required to delete temp file which created during asp.net pages hit.you can delete this temp files either mannualy or by coding.

to delete temp file using Coding follow the below Step.

Store Temp File Path in Session["pdfpath"]


Write below code in global.aspx


void Session_End(object sender, EventArgs e) {
if (System.IO.File.Exists(Session["pdfpath"].ToString()))System.IO.File.Delete(Session["pdfpath"].ToString()); }

in web.config
<sessionState mode="InProc" timeout="20">
sessionState>




this Code delete your temp file.

Please do not forgot to comment on articles.


Saturday, August 8, 2009

'sys' is undefined


Problem :-  'sys' is undefined

Solution :-


1. Sys undefined usually indicates that the framework scripts didn't load. In your case, you shouldn't drop the script files directly under the script path: there is versioning involved and the directory structure must be exactly what the script manager expects.
If you look at the html source code in the browser, you'll see what the expected url is for each script. You need to reproduce that directory structure on your server. The directory structure of the library as downloaded from the asp.net site should already be the right one.


2. There are many reasons for getting this error . Few of them i encountered were
1) Web.config not getting updated according to the AJAX enabled website requirement  because most of us are using in existing application and trying to make it work and we miss few entries . Best option is to create an AJAX enabled website and put all the web.config entries into exixting application's web.config or put the exixting aplication web.config entries into newly created website web.config and replace the original one  with new one.
2) If issue is not related to web.config  then its possible that system is not allowing IIS to access the file system where the MicrosoftAjaxLibrary exists usually C: drive. In most of the production environment its not allowed so we need to make use of scriptpath attribute of scriptmanager and it may solve the issue as mentioned in above post where scripts folder is in ur website directory and all the ajaxlibrary java script files are copied into this folder.
3) Even after this it doesnt work then you need to look if the file can be accessible from client machine may be system configuration is not allowing to access it use HTTPWATCH or FIDDLER to see if 404 is coming if so then it has to do with system settings in my case it was ISAPI filter which was causing it and it was URLSCAN security tool which was not allowing it why because of MicrosoftAjaxLibrary contains the folder names which has DOTS(.) like System.Web.Extensions . So we need to modify the .ini file for urlscan security tool ISAPI filter. To do this you need to check if this filter is added in ur IIS if so then you need to go to WINDIR%\System32\Inetsrv\URLscan  and edit th .ini file and make AllowDotInPath=1  this will solve the issue.
 These were my analysis hope it helps . again i reiterate that there is no fix scenario why this errors comes.Different person can get same error for different reasons.




ASP.NET 2.0 - Accessing controls in the previous page


One of the problems faced by us in ASP.NET 1.x versions is the inability to transfer data between pages easily. Since ASP.NET 1.x pages postback to the same page by default, and you cannot do a post to another page (unless you remove the runat="server" and other messy things), accessing the controls in the previous page becomes very difficult unlike classic ASP where you have a action tag to specify the new page and you can use the Request.Form to access the previous page values.
There is a more effective way of accessing the Controls in the previous page in ASP.NET 2.0. Its using the PreviousPage property of the Page.

Say we have a page Default.aspx with a Textbox "Text1" and a Button "Button1".

We can access the controls in Default.aspx from another page by the following steps:-

1. Setting the PostBackUrl property of the Button to the New Page, as follows:-



2. Then, in the NewPage.aspx.cs, you can access the TextBox control on Default.aspx as follows:-

public void page_load()
{
if(!IsPostBack)
{
TextBox tb = (TextBox)PreviousPage.FindControl("Text1");
Response.Write(tb.Text);}
}

Note that a new TextBox tb is declared and typecasted using the PreviousPage and FindControl of the ID of the Control in the Previous Page.  However, to retain the value across postbacks within the new page, its better to assign the text to a TextBox or Label in the NewPage.aspx such that its value is not lost across postbacks.  The reason behind is that, the PreviousPage becomes invalid once you postback in the same page. 



We could still achieve this in ASP.NET 1.x versions by using the Server.Transfer but Server.Transfer has other undesirable effects like URL not updated in the browser and limitation within the application etc., 






Note :- This artical taken from  http://forums.asp.net