Tuesday, April 12, 2016
500: Internal Server when call Webservice in jquery and Asp.net
0 comments Posted by Duc Nguyen at 2:55 AM
maxJsonLength="50000000"/>
Sunday, April 10, 2016
Asp.net C# + Dropzone js : Easy way to upload images [Drag & Drop feature]
0 comments Posted by Duc Nguyen at 8:08 PMGeneric Handler ashx file : Post send JSON data in Asp.net c#, jQuery
0 comments Posted by Duc Nguyen at 8:00 PM$("#bntSubmit").on('click', function (e) {
// Initialize the object, before adding data to it.
// { } is declarative shorthand for new Object()
var obj = {};
obj.first_name = $("#txtFirstName").val();
obj.last_name = $("#txtLastName").val();
obj.qualification = $("#txtQualication").val();
obj.age = $("#txtAge").val();
//In order to proper pass a json string, you have to use function JSON.stringfy
var jsonData = JSON.stringify(obj);
$.ajax({
url: 'myGenericHandler.ashx',
type: 'POST',
data: jsonData,
success: function (data) {
console.log(data);
alert("Success :" + data);
},
error: function (errorText) {
alert("Wwoops something went wrong !");
}
});
e.preventDefault();
});
# Add Generic Handler ( ashx file) in your Asp.net Application.
using System.Web.Script.Serialization;
using System.IO;
// we create a userinfo class to hold the JSON value
public class userInfo
{
public string first_name { get; set; }
public string last_name { get; set; }
public string qualification { get; set; }
public string age { get; set; }
}
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
try
{
string strJson = new StreamReader(context.Request.InputStream).ReadToEnd();
//deserialize the object
userInfo objUsr = Deserialize(strJson);
if (objUsr != null)
{
string fullName = objUsr.first_name + " " + objUsr.last_name;
string age = objUsr.age;
string qua = objUsr.qualification;
context.Response.Write(string.Format("Name :{0} , Age={1}, Qualification={2}", fullName, age, qua));
}
else
{
context.Response.Write("No Data");
}
}
catch (Exception ex)
{
context.Response.Write("Error :" + ex.Message);
}
}
if (objUsr != null)
{
string fullName = objUsr.first_name + " " + objUsr.last_name;
string age = objUsr.age;
string qua = objUsr.qualification;
context.Response.Write(string.Format("Name :{0} , Age={1}, Qualification={2}", fullName, age, qua));
}
else
{
context.Response.Write("No Data");
}
}
catch (Exception ex)
{
context.Response.Write("Error :" + ex.Message);
}
}
<%@ WebHandler Language="C#" Class="myGenericHandler" %>
using System;
using System.Web;
using System.Web.Script.Serialization;
using System.IO;
public class myGenericHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
try
{
string strJson = new StreamReader(context.Request.InputStream).ReadToEnd();
//deserialize the object
userInfo objUsr = Deserialize(strJson);
if (objUsr != null)
{
string fullName = objUsr.first_name + " " + objUsr.last_name;
string age = objUsr.age;
string qua = objUsr.qualification;
context.Response.Write(string.Format("Name :{0} , Age={1}, Qualification={2}", fullName, age, qua));
}
else
{
context.Response.Write("No Data");
}
}
catch (Exception ex)
{
context.Response.Write("Error :" + ex.Message);
}
}
public bool IsReusable
{
get
{
return false;
}
}
// we create a userinfo class to hold the JSON value
public class userInfo
{
public string first_name { get; set; }
public string last_name { get; set; }
public string qualification { get; set; }
public string age { get; set; }
}
// Converts the specified JSON string to an object of type T
public T Deserialize(string context)
{
string jsonData = context;
//cast to specified objectType
var obj = (T)new JavaScriptSerializer().Deserialize(jsonData);
return obj;
}
}
if (objUsr != null)
{
string fullName = objUsr.first_name + " " + objUsr.last_name;
string age = objUsr.age;
string qua = objUsr.qualification;
context.Response.Write(string.Format("Name :{0} , Age={1}, Qualification={2}", fullName, age, qua));
}
else
{
context.Response.Write("No Data");
}
}
catch (Exception ex)
{
context.Response.Write("Error :" + ex.Message);
}
}
public bool IsReusable
{
get
{
return false;
}
}
// we create a userinfo class to hold the JSON value
public class userInfo
{
public string first_name { get; set; }
public string last_name { get; set; }
public string qualification { get; set; }
public string age { get; set; }
}
// Converts the specified JSON string to an object of type T
public T Deserialize
{
string jsonData = context;
//cast to specified objectType
var obj = (T)new JavaScriptSerializer().Deserialize
return obj;
}
}
Wednesday, April 6, 2016
Download and install Microsoft SQL Server 2008 R2 Express
0 comments Posted by Duc Nguyen at 6:56 PMIntroduction
Instructions
- Download Microsoft SQL Server 2008 R2 Express. There are 32-bit (x86, file name SQLEXPRWT_x86_ENU.exe) and 64-bit (x64, file name SQLEXPRWT_x64_ENU.exe) versions available for download. If you are unsure if your operating system is 64-bit, download the 32-bit version:
• Microsoft SQL Server 2008 R2 Express 32-bit (x86)
- or -
• Microsoft SQL Server 2008 R2 Express 64-bit (x64)
This download also includes basic management tools for the database server.
Important: You may have to install Microsoft .Net Framework 3.5 SP1, Windows Installer 4.5 and Windows PowerShell 1.0 before installing Microsoft SQL Server 2008 R2 (typically required for Windows XP and Windows Server 2003).- Open the downloaded file (SQLEXPRWT_x86_ENU.exe or SQLEXPRWT_x64_ENU.exe) to start the SQL Server Installation Center.
- Click on New installation or add features to an existing installation.
- Follow the installation wizard.
- When prompted for the Instance Configuration, select Default instance.
- Follow the installation wizard.
- When prompted for the Database Engine Configuration, it is recommended that you select Mixed Mode (SQL Server authentication and Windows authentication) and provide a strong password.
- Follow the installation wizard and wait until the installation is complete.
- Go to Start > All Programs > Microsoft SQL Server 2008 R2 > Configuration Tools > SQL Server Configuration Manager.
- Open the node SQL Server Network Configuration and select Protocols for MSSQLSERVER.
- Double-click on TCP/IP.
- Set Enabled to Yes.
- Click on OK.
- Close the SQL Server Configuration Manager.
- Restart the computer or the SQL Server service.
Labels: SQL Server 2005, SQL Server 2008 Express
Wednesday, March 30, 2016
Labels: C#, Javascript, jquery
Tuesday, March 22, 2016
See more:
http://1stwebmagazine.com/tipsy-jquery-tooltip
Demo:
http://1stwebmagazine.com/demo/tipsy-jquery-tooltip.html
Monday, January 25, 2016
Sunday, January 24, 2016
Thursday, January 21, 2016
The Problem
So, you’re trying to publish a desktop app via the Visual Studio 2010 Click Once publishing, and you’re having problems with Visual Studio 2010 Click Once publishing? Are you getting errors like the part belowFollowing errors were detected during this operation.Even though you are not using a .sdf file
* [2/22/2012 1:45:21 PM] System.Deployment.Application.DeploymentDownloadException (Unknown subtype)
– Downloading http://www.Domain.com/PublishFiles/SomeApp/Application Files/ReportingApp_1_0_0_8/App_Data/Reporting.sdf.deploy did not succeed.
– Source: System.Deployment
– Stack trace:
at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
at System.Deployment.Application.SystemNetDownloader.DownloadAllFiles()
at System.Deployment.Application.FileDownloader.Download(SubscriptionState subState)
at System.Deployment.Application.DownloadManager.DownloadDependencies(SubscriptionState subState, AssemblyManifest deployManifest, AssemblyManifest appManifest, Uri sourceUriBase, String targetDirectory, String group, IDownloadNotification notification, DownloadOptions options)
at System.Deployment.Application.ApplicationActivator.DownloadApplication(SubscriptionState subState, ActivationDescription actDesc, Int64 transactionId, TempDirectory& downloadTemp)
at System.Deployment.Application.ApplicationActivator.InstallApplication(SubscriptionState& subState, ActivationDescription actDesc)
at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl)
at System.Deployment.Application.ApplicationActivator.ActivateDeploymentWorker(Object state)
— Inner Exception —
System.Net.WebException
– The remote server returned an error: (404) Not Found.
– Source: System
– Stack trace:
at System.Net.HttpWebRequest.GetResponse()
at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
The Cause
Somewhere along the way you did have a .sdf file in the app_data folder, and the Click Once deploy manifest listed it. The manifest looks for it and does not find it, and would not find it anyway due to .sdf not being an accepted mime type on your server.The Solution
Make sure that there are no .sdf files in the app_data folder, do a grep for any .sdf files, and then delete the web directories containing the files, the republish via click onceThursday, December 17, 2015
Example:
<system.web>
<sessionState timeout="60"></sessionState>
</system.web>
if not working, try this:
1, go to IIS
2, Application Pools --> Advanced Setting
--> change Time in Idle Time-out
--> Done!