Wednesday 4 March 2015

ajax pro is not working with .Net Framework 4.0 and visual studio 2013

If you guys are converting from .net2.0 to 4.0 and visual studio 2013 then you may experience that your ajax pro will not work.

Ajax pro is work with classic managed pipeline mode.

In visual studio 2013 there is a facility to change managed pipeline mode via website Property window.










By default it is integrated for me.

So i change it to Classic and Ajax pro is working.

Thursday 12 February 2015

Potentially dangerous Request.Form value was detected

Sys.WebForms.PageRequestManagerServerErrorException:An unknown error occurred while processing the request on the server. The status code returned from the server was: 500
Today i was stucked in one issue after converting my website from .net2.0 to 4.0.

In .net2.0 page is working fine with ValidateRequest="false" but after converting to 4.0 it's throwing error

Sys.WebForms.PageRequestManager.prototype._endPostBack  ScriptResource.axd
 Sys.WebForms.PageRequestManagerServerErrorException:An unknown error occurred while processing the request on the server. The status code returned from the server was: 500


I tried different way to solve the issue but no luck.at the end i tried to remove ValidateRequest="false" attribute from page and then i got actual error which is that "Potentially dangerous Request.Form value was detected"

It was because i am storing some xml values in hidden field.but the strange in .net2.0 it was working fine then what is the issue in 4.0.

I think in .net4.0 Microsoft has change  some logic of validating request of web page.

So currently i have 2 solution to solve the issue.

1. Change the code and remove xml things from hidden variable.
2. I can validate page request as per .net framework 2.0

So Solution no 2 is better for me.

I have added following attribute to web.config

<httpRuntime requestValidationMode="2.0"/>

Saturday 31 August 2013

Download interrupted in IE10


In IE 10 you guys may get error Download interrupted error for some files which is grater then 20mb.

It's error occurred in IE10 only.

So For that you need to change something in your code.

If you use Response.close(); then remove it.

Just wirte something below.

Response.Flush();
Response.End();

For more info visit
http://blogs.msdn.com/b/ieinternals/archive/2012/07/16/content-length-and-transfer-encoding-validation-in-ie10-download-manager-couldnt-be-downloaded-retry-cancel.aspx

Tuesday 22 January 2013

Set Wallpaper using C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;
using Microsoft.Win32;  

namespace CustomWallpaper
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private static readonly UInt32 SPI_SETDESKWALLPAPER = 0x14;
        private static readonly UInt32 SPIF_UPDATEINIFILE = 0x01;
        private static readonly UInt32 SPIF_SENDWININICHANGE = 0x02;

        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        private static extern Int32 SystemParametersInfo(
            UInt32 action, UInt32 uParam, String vParam, UInt32 winIni);

        private void Form1_Load(object sender, EventArgs e)
        {
            string strPath = "D:\\Projects\\Wallpaper\\Wallpaper.jpg";

            
            if (File.Exists(strPath))
            {
                SetWallpaper(strPath);
            }
            else
            {
                 strPath = "D:\\Projects\\Wallpaper\\Wallpaper.jpeg";
                if (File.Exists(strPath))
                { 
                    SetWallpaper(strPath); 
                }
                else
                {
                    strPath = "D:\\Projects\\Wallpaper\\Wallpaper.png";
                    if (File.Exists(strPath))
                    {
                        SetWallpaper(strPath); 
                    }
                    else
                    {
                        MessageBox.Show("Wallpaper.jpg Or Wallpaper.jpeg OR Wallpaper.png is not found on this path D:\\Projects\\Wallpaper\\");
                        this.Close();
                    }
                }
            }
        }

        private void SetWallpaper(string path)
        {
            SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, path,SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);

            RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true);            
            key.SetValue(@"WallpaperStyle", 2.ToString());
            key.SetValue(@"TileWallpaper", 0.ToString());            
            this.Close();
        }
    }
}


Monday 7 January 2013

Dialog is not a function in asp.net mvc

Guys you may get error when using jquery dialog function in your mvc application.It's because by default visual studio importing script which is old version script and also it's not importing jquery-ui-1.9.2.custom.js.

Dialog is function of ui js.

Here below you can see how js import by default in _layout.cshtml by visual studio. 




you have to change this and cut it and paste to top of the page because if you import jquery ui in top of the page then you may get the error that jquery is undefined. so as we are doing always put it to top of the page like as shown in below image. 



Now you guys have to update the version of js like below.



Now finally you guys have to update all new css version of ui inContent -->themes-->base