Posts

Showing posts with the label Error

How to set max limt of File Upload in Asp.net

Many times I faced the same problem with all my applications, that is Max size of file to be uploaded to server. By default, the maximum size limit of a file to be uploaded to a server using the ASP.NET FileUpload control is 4MB. You cannot upload anything that is larger than this limit. If you wants to upload a file more the size of 4 MB which is by default, you have to make some changes in the application's web.config: <configuration> <system.web> <httpRuntime maxRequestLength="xxx" /> </system.web> </configuration> Below is the small description of the parameters attributes. maxRequestLength - Attribute limits the file upload size for ASP.NET application. This limit can be used to prevent denial of service attacks (DOS) caused by users posting large files to the server. The size specified is in kilobytes. As mentioned earlier, the default is "4096" (4 MB). Max value is "1048576" (1 GB) for .NET Framework ...

Disbale JIT in .net / Application level Exception handling in .net

Image
Download Code Example I was developing windows application for a well known company of World. This application was in C#.net 2005. As per requirement I have to show user defined message whenever an Exception occurs in the application. The answer is very simply write a simple Try{},Catch{} statement to handle exception. Suppose I have a code of 1000 line unwanted code and error handling creates extra thread while executing the application. I had search on the internet and found a solution to disable the JIT debugger. It works but still it is showing the application information related to functions etc. used in the code. Now, a major issue had risen from client, i.e. he don’t want to show JIT information to user he wants to show his own message whenever any Exception occurs. Offf…. Now that’s the task to which needs to done. I cannot use Try{},Catch{} as this decrease the application performance. Finally I came to the solution. I had wired an event with application to handle applicatio...

C# too many database connections error

Every database is having some number of connection limits which you can increase up to an extend. But database can support up to an number of connections. This error occurs when we open a connection and forget to close that. Verify each line of your code and make sure you had closed the connection after completing your database operations. I had faced this error in C# My sql application. I had crossed verify my code and find a code where I am not closing my connection after completing my operations. I had simply write connection.Close(); and it had worked.

How to use DateDiff Function in C#

How to use DateDiff Function in C#. As earlier in ASP and VB6 we have too may conversion and date time functions. After working for so many years, we all had become habitual of working with the same. We have almost all the functions available in c#. But, sometimes lost control on some functions. Like for datediff WE have to write so much code in C#. At this moment we just remember functions of VB. Now, say thanks to Microsoft… What we can use is:- Add a reference of Microsoft.VisualBasic and access the DateDiff function like following ex. long nYears = Microsoft.VisualBasic.DateAndTime.DateDiff(Microsoft.VisualBasic.DateInterval.Year, dt, dtNow, Microsoft.VisualBasic.FirstDayOfWeek.System, Microsoft.VisualBasic.FirstWeekOfYear.System); By using the reference of visual basic you can use any function of Visual Basic or vice-versa.

How to Compare Files -File Compare

In contemporary world we have so many powerfull tools for version control like VSS, Tortoise SVN etc. With help of there tools we can check different version of file with dates and other information. But, what if I have to simply compare two files like notepad, word etc. Let's take an simle example. I had made a file .cs file a year ago. I had made so many changes in that a year. Now I am facing some problem in my code. I have only option to check older versions of my file, which is a time consuming job. Means after each version I have to build and test my code. Let me suggest you a simple solution which I had found on net using scootter softwares (Download Beyond Compare) Beyond Compare allows you to quickly and easily compare your files and folders. By using simple, powerful commands you can focus on the differences you're interested in and ignore those you're not. You can then merge the changes, synchronize your files, and generate reports for your records. You can co...

A name was started with an invalid character. Error processing resource

This error fires when you run your application on local host. Generally the reason behind this error is configuration of IIS. The general cause of this error is installation of .net 2005 before installing IIS To know how to configure IIS click here. Here is the solution of this error Go to run type cmd Browse for windows directory: For ex. C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ aspnet_regiis.exe –i Or C:\WINNT\Microsoft.NET\Framework\v2.0.50727\ aspnet_regiis.exe –i Hope this will work

Validation of viewstate MAC failed.

Image
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster. I am facing this error from last two days, I tried so many resolutions to resolve this problem. I had tried to know the reason of this error but, unfortunately I am not able to reach the cause of this error. But, I had find a solution of this error. Update your web.config with following attributes. <pages validateRequest="false" enableEventValidation="false" viewStateEncryptionMode ="Never" enableViewStateMac="false"> Download Sample Web.config

aspnet_merge.exe exited with code '1'

This is a major problem which will normally faced by new users of .net. The main reason behind the problem is the duplicate "Inherits" name of pages. You can easily resolve this problem by renaming the duplicate inherit names of Pages. Let me describe this by giving an simple ex. steps :- 1) Make a new c# website. 2) By default an page default.aspx will appear. 3 Copy default.aspx and paste 4) Rename copy of default to "Default2.aspx" 5) Then try to make build. 6) It will show errors Here, is the solution 1) Open default.aspx 2) Check Inherits attribute of page in page directive. it is "_Default" by default 3) Open default2 4) Check Inherits attribute of default2 in page directive. it is "_Default" 5) Change Inherits attribute of default2 to "_Default2" 6) Build application Now build successfully. This is the solution which I have explained with the help of small ex. For any help please mail on narendersinghkahlon@gmail.com