Posts

System.Security.SecurityException: Request failed. issue on web server [resolved]

While hosting your website on shared hosting server you might get the System.Security.SecurityException: Request failed issue which will give you below stack trace on landing page of the website. Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. You can add below code to your Application web.config file to resolve it permanently   < system.web > < customErrors mode =" Off" / > < trust level =" Full" / > < /system.web >     This issue might occur in the case when serve

Cannot create type 'webservice' error solution

We create a web-service in development environment it working fine. But when we deploy the developed web service in production server many people get the Cannot create type 'some web-service  error. After finding the solution on the net i got one resolution which i am going to share now. To get ride of this error we need to re-install the .net framework 2.0 in IIS. This is essential to run web service on server. Following is the step you need to follow to register the .net framework in IIS. Open command prompt Then type >CD  C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ aspnet_regiis.exe -i After above instruction the .net framework will be register in IIS. Now run the web service again. it should be run normally. Hurray you did it

Disable button after click in asp.net

To prevent double submit a form by user we need to restrict the user to click the button again. The idea is that we will use JavaScript to disable the button once user clicks first time. Add the following lines on .aspx page <asp:Button ID="btnProcess" runat="server" onclick="btnProcess_Click" Text="Process" /> Add the following line on .aspx.cs page (Page_Load). string strProcessScript = "this.value='Processing...';this.disabled=true;"; btnProcess.Attributes.Add("onclick", strProcessScript + ClientScript.GetPostBackEventReference(btnProcess, "").ToString()); This will disable Button, and then change the text of the button " Processing... ", and then continue on with the server side event btnProcess_OnClick event handler.

Prevent ASP.NET Forms Authentication from Timing Out on a Shared Hosting

I’m hosting a website on a shared hosting server. This site uses Forms Authentication to generate the session cookie that authenticates my users. Everything worked fine with the site, including authentication, until I tried to make it so my authentication cookies didn’t expire every 20 minutes, which is the default expiration setting for Forms Authentication I have set following settings to my web.config <authentication mode="Forms" > <forms loginUrl="~/Account/LogOn" timeout="2880" /> </authentication> but even though the user log outs from the system in 2 mins its irritating to user. To solve the issue we need to set machine key into the web.config file. To generate the machine key use following code snippet. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Security.Cryptography; namespace keygenerator { class Program { static void Main(string[] argv

File extension validation using javascript in MVC

This is article which demonstrate the validation of allowed file extension for upload of files in MVC using javascript. In this article i have used validation for valid image format like Jpeg, Jpg,Gif and png image format. If users ties to upload any other file apart from above mentioned file then the javascript function will shows proper message to user to select appropriate files. I have used html input file control for uploading of files in MVC application. following is the html code for it. <body> <div style="height:50px; padding-bottom:20px;"> @using (@Html.BeginForm("Create","FileUpload",FormMethod.Post,new{ enctype = "multipart/form-data"})) { <input type="file" id="file1" name="sdf" style=" margin-top:0px;" onchange="if( CheckExtention(this.value) ) {parent.ShowHideImage(true);this.form.submit();}" /> } </div> </body> and followi