Friday, November 30, 2012
Microsoft Details Its Plans For The Future Of ASP.NET after Windows 8
http://www.webpronews.com/microsoft-details-its-plans-for-the-future-of-asp-net-2012-11
Sumamary:
- SignalR
- Web API to support Windows Stores apps
- MVC SPA singal page application
- MVC facebook template
- MVC Mobile tempalet
Sumamary:
- SignalR
- Web API to support Windows Stores apps
- MVC SPA singal page application
- MVC facebook template
- MVC Mobile tempalet
Thursday, November 29, 2012
How to read database connection string from web.config?
System.Configuration.ConfigurationManager.ConnectionStrings["connectionStringName"].ConnectionString;
How to generate ASPX dynamically?
By Razor engine
http://razorengine.codeplex.com/
string template = @"<%@ Control Language="C#" ClassName="@Model.Name" %>";
string result = Razor.Parse(template, new { Name = "Classname" });
http://razorengine.codeplex.com/
string template = @"<%@ Control Language="C#" ClassName="@Model.Name" %>";
string result = Razor.Parse(template, new { Name = "Classname" });
Wednesday, November 28, 2012
How to add dynamic field in OTRS?
1. Cretae dynamic field first
Admin->Ticket->Dynamic Field
2. Change configuration to make avaiblae in different view
Goto Admin -> SysConfig
search by ###DynamicField
Enable the dynamic field just created
There are a lot of setting for different views.
Tuesday, November 27, 2012
Cleaner Conditional HTML Attributes In Razor Web Pages
http://www.mikesdotnetting.com/Article/201/Cleaner-Conditional-HTML-Attributes-In-Razor-Web-Pages
<div class="@(record.Index % 2 == 0 ? "even" : "odd")">
Monday, November 26, 2012
The Future of Programming
http://www.blogger.com/blogger.g?blogID=2311653455419580222#editor/src=sidebar
Using examples and objects is the future of programming because it is closer to how our mind works.
Using examples and objects is the future of programming because it is closer to how our mind works.
Friday, November 23, 2012
ASP.NET web SQL Utility
http://www.codeproject.com/Articles/15408/Web-SQL-Utility
A nice and small tool to show the query result for MS SQL Server and Access database
A nice and small tool to show the query result for MS SQL Server and Access database
Thursday, November 22, 2012
Make a Captcha Image Validation with Jquery and MVC
http://www.codeproject.com/Tips/494536/Make-a-Captcha-Image-Validation-with-Jquery-and-MV
<script type="text/javascript" language="javascript">
$(document).ready(function () {
loadCaptcha();
});
function loadCaptcha() {
$.ajax({
type: 'GET', url: 'Home/generateCaptcha',
contentType: "application/json; charset=utf-8",
dataType: "json",
cache: false,
success: function (data) { $("#m_imgCaptcha").attr('src', data); },
error: function (data) { alert("Error while loading captcha image") }
});
}
</script>
public ActionResult generateCaptcha()
{
System.Drawing.FontFamily family = new System.Drawing.FontFamily("Arial");
CaptchaImage img = new CaptchaImage(150, 50, family);
string text = img.CreateRandomText(4) + " " + img.CreateRandomText(3);
img.SetText(text);
img.GenerateImage();
img.Image.Save(Server.MapPath("~") + this.Session.SessionID.ToString() + ".png", System.Drawing.Imaging.ImageFormat.Png);
Session["captchaText"] = text;
return Json(this.Session.SessionID.ToString() + ".png?t=" + DateTime.Now.Ticks, JsonRequestBehavior.AllowGet);
}
Wednesday, November 21, 2012
What is OTRS?
OTRS is an Open-source Ticket Request System, developed by Perl, default database is MySQL.
http://www.otrs.com
Following link is a group of tips for integrating OTRS into .Net project
http://rayaspnet.blogspot.ca/search/label/OTRS
http://www.otrs.com
Following link is a group of tips for integrating OTRS into .Net project
http://rayaspnet.blogspot.ca/search/label/OTRS
Tuesday, November 20, 2012
How to call OTRS web service in C#?
There are two ways for calling web service to create/get/search ticket in OTRS:
First way: call RPC.pl
Second way: GenericInterface
Follwoing are the steps for RPC:
1. Setup SOAP user in OTRS:
Log in OTRS with FULL admin permission
Admin -> SysConfig -> Framework -> Core: SOAP
Add and enable SOAP user and password
2. In C# project, prepare SOAP request like following
Then make Webrequest for URL: http://localhost/otrs/RPC.pl
<?xml version=""1.0"" encoding=""utf-8""?>
<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns:soapenc=""http://schemas.xmlsoap.org/soap/encoding/""
xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
soap:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/""
xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">
<soap:Body>
<Dispatch xmlns=""/Core"">
<c-gensym4 xsi:type=""xsd:string"">soapUserName</c-gensym4>
<c-gensym6 xsi:type=""xsd:string"">soapUserPassword</c-gensym6>
<c-gensym8 xsi:type=""xsd:string"">TicketObject</c-gensym8>
<c-gensym10 xsi:type=""xsd:string"">TicketSearch</c-gensym10>
<c-gensym57 xsi:type=""xsd:string"">Limit</c-gensym57>
<c-gensym59 xsi:type=""xsd:int"">10000</c-gensym59>
<c-gensym8 xsi:type=""xsd:string"">Result</c-gensym8>
<c-gensym10 xsi:type=""xsd:string"">ARRAY</c-gensym10>
<c-gensym57 xsi:type=""xsd:string"">UserID</c-gensym57>
<c-gensym59 xsi:type=""xsd:int"">1</c-gensym59>
</Dispatch>
</soap:Body>
</soap:Envelope>
3. The result is in the XML format
If you meet problem, please give me an email, may I help a little bit. wangchiwei@gmail.com
First way: call RPC.pl
Second way: GenericInterface
Follwoing are the steps for RPC:
1. Setup SOAP user in OTRS:
Log in OTRS with FULL admin permission
Admin -> SysConfig -> Framework -> Core: SOAP
Add and enable SOAP user and password
2. In C# project, prepare SOAP request like following
Then make Webrequest for URL: http://localhost/otrs/RPC.pl
<?xml version=""1.0"" encoding=""utf-8""?>
<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns:soapenc=""http://schemas.xmlsoap.org/soap/encoding/""
xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
soap:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/""
xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">
<soap:Body>
<Dispatch xmlns=""/Core"">
<c-gensym4 xsi:type=""xsd:string"">soapUserName</c-gensym4>
<c-gensym6 xsi:type=""xsd:string"">soapUserPassword</c-gensym6>
<c-gensym8 xsi:type=""xsd:string"">TicketObject</c-gensym8>
<c-gensym10 xsi:type=""xsd:string"">TicketSearch</c-gensym10>
<c-gensym57 xsi:type=""xsd:string"">Limit</c-gensym57>
<c-gensym59 xsi:type=""xsd:int"">10000</c-gensym59>
<c-gensym8 xsi:type=""xsd:string"">Result</c-gensym8>
<c-gensym10 xsi:type=""xsd:string"">ARRAY</c-gensym10>
<c-gensym57 xsi:type=""xsd:string"">UserID</c-gensym57>
<c-gensym59 xsi:type=""xsd:int"">1</c-gensym59>
</Dispatch>
</soap:Body>
</soap:Envelope>
3. The result is in the XML format
If you meet problem, please give me an email, may I help a little bit. wangchiwei@gmail.com
How I went from $100-an-hour programming to $X0,000-a-week consulting.
https://training.kalzumeus.com/newsletters/archive/consulting_1
- Clients Pay For Value, Not For Time
- Charging Weekly: It Makes Everything Automatically Better
- Getting Clients: The Importance Of Social Proof
- Scaling A Consulting Business
- Hybridizing Consultancies With Product Businesses
- Clients Pay For Value, Not For Time
- Charging Weekly: It Makes Everything Automatically Better
- Getting Clients: The Importance Of Social Proof
- Scaling A Consulting Business
- Hybridizing Consultancies With Product Businesses
Monday, November 19, 2012
Asynchronous partial views
http://blog.michaelckennedy.net/2012/11/13/improve-perceived-performance-of-asp-net-mvc-websites-with-async-partialviews/
Friday, November 16, 2012
The Eight Levels of Programmers
http://www.codinghorror.com/blog/2009/04/the-eight-levels-of-programmers.html
Thursday, November 15, 2012
How to get current assembly version and build time?
private static string GetAssemblyVersionBuildDate()
{
string filePath = System.Reflection.Assembly.GetCallingAssembly().Location;
const int c_PeHeaderOffset = 60;
const int c_LinkerTimestampOffset = 8;
byte[] b = new byte[2048];
System.IO.Stream s = null;
try
{
s = new System.IO.FileStream(filePath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
s.Read(b, 0, 2048);
}
finally
{
if (s != null)
{
s.Close();
}
}
int i = System.BitConverter.ToInt32(b, c_PeHeaderOffset);
int secondsSince1970 = System.BitConverter.ToInt32(b, i + c_LinkerTimestampOffset);
DateTime dt = new DateTime(1970, 1, 1, 0, 0, 0);
dt = dt.AddSeconds(secondsSince1970);
dt = dt.AddHours(TimeZone.CurrentTimeZone.GetUtcOffset(dt).Hours);
return "v"+ System.Reflection.Assembly.GetCallingAssembly().GetName().Version.ToString() + " "+ dt.ToString();
}
How to access session variables from anywhere in ASP.NET?
By full path like this:
System.Web.HttpContext.Current.Session["sessionVarName"];
How to remove local mapping in TFS?
How to remove local mapping in TFS?
1. In team exploerer, Open that folder
2. Go File -> Source Control -> Remove mapping (It is dynamic menu item)
1. In team exploerer, Open that folder
2. Go File -> Source Control -> Remove mapping (It is dynamic menu item)
Coexistence of projects between Visual Studio 2010 and 2012
http://weblogs.asp.net/sreejukg/archive/2012/10/17/coexistence-of-projects-between-visual-studio-2010-and-2012.aspx
Wednesday, November 14, 2012
How to parse html tag by HTML Agility pack?
http://www.codeplex.com/htmlagilitypack
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(@"<html><body><p><table id=""foo""><tr><th>hello</th></tr><tr><td>world</td></tr></table></body></html>");
foreach (HtmlNode table in doc.DocumentNode.SelectNodes("//table")) {
Console.WriteLine("Found: " + table.Id);
foreach (HtmlNode row in table.SelectNodes("tr")) {
Console.WriteLine("row");
foreach (HtmlNode cell in row.SelectNodes("th|td")) {
Console.WriteLine("cell: " + cell.InnerText);
}
}
}
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(@"<html><body><p><table id=""foo""><tr><th>hello</th></tr><tr><td>world</td></tr></table></body></html>");
foreach (HtmlNode table in doc.DocumentNode.SelectNodes("//table")) {
Console.WriteLine("Found: " + table.Id);
foreach (HtmlNode row in table.SelectNodes("tr")) {
Console.WriteLine("row");
foreach (HtmlNode cell in row.SelectNodes("th|td")) {
Console.WriteLine("cell: " + cell.InnerText);
}
}
}
CDN for jquery UI themes
http://stackoverflow.com/questions/1348559/are-there-hosted-jquery-ui-themes-anywhere
base: Google CDN, Microsoft CDN
black-tie: Google CDN, Microsoft CDN
blitzer: Google CDN, Microsoft CDN
cupertino: Google CDN, Microsoft CDN
dark-hive: Google CDN, Microsoft CDN
dot-luv: Google CDN, Microsoft CDN
eggplant: Google CDN, Microsoft CDN
excite-bike: Google CDN, Microsoft CDN
flick: Google CDN, Microsoft CDN
hot-sneaks: Google CDN, Microsoft CDN
humanity: Google CDN, Microsoft CDN
le-frog: Google CDN, Microsoft CDN
mint-choc: Google CDN, Microsoft CDN
overcast: Google CDN, Microsoft CDN
pepper-grinder: Google CDN, Microsoft CDN
redmond: Google CDN, Microsoft CDN
smoothness: Google CDN, Microsoft CDN
south-street: Google CDN, Microsoft CDN
start: Google CDN, Microsoft CDN
sunny: Google CDN, Microsoft CDN
swanky-purse: Google CDN, Microsoft CDN
trontastic: Google CDN, Microsoft CDN
ui-darkness: Google CDN, Microsoft CDN
ui-lightness: Google CDN, Microsoft CDN
vader: Google CDN, Microsoft CDN
How to solve problem, jQuery UI datepicker not working in IE9?
http://rayaspnet.blogspot.ca/2011/12/how-to-avoid-quirks-mode-in-ie.html
Put this line into the first place
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
</head>
or set this meta tag in IIS server into HTTP response headers.
Reference:
How to avoid compatibility view and quirk mode in IE?
Put this line into the first place
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
</head>
or set this meta tag in IIS server into HTTP response headers.
Reference:
How to avoid compatibility view and quirk mode in IE?
Synchronizing webpages across devices with SignalR
http://lostechies.com/erichexter/2012/10/30/synchronizing-webpages-across-devices-home-automation/
Tuesday, November 13, 2012
ASP.NET SignalR
http://weblogs.asp.net/davidfowler/archive/2012/11/11/microsoft-asp-net-signalr.aspx
Monday, November 12, 2012
How to set field value by reflection in C#?
Class1 result1 = new Class1();
FieldInfo[] fields = result1.GetType().GetFields(BindingFlags.Public| BindingFlags.Instance);
foreach (var f in fields)
{
f.SetValue(result1, Convert.ChangeType("1", f.FieldType));
}
FieldInfo[] fields = result1.GetType().GetFields(BindingFlags.Public| BindingFlags.Instance);
foreach (var f in fields)
{
f.SetValue(result1, Convert.ChangeType("1", f.FieldType));
}
Friday, November 9, 2012
Thursday, November 8, 2012
How to solve problem "(OS 10013)An attempt was made to access a socket in a way forbidden by its access permissions. : make_sock: could not bind to address 0.0.0.0:80"
This error happens while install Appache, but port 80 is used by other application
Disable all of applications for Port 80
- Run netstat -ao to check if any application is listening this port
http://www.sitepoint.com/unblock-port-80-on-windows-run-apache/
Disable all of applications for Port 80
- Run netstat -ao to check if any application is listening this port
http://www.sitepoint.com/unblock-port-80-on-windows-run-apache/
How to disable port 80 on Windows 7 for OTRS / apache?
- Run netstat -ao to check if any application is listening this port
The disable one by one
http://www.sitepoint.com/unblock-port-80-on-windows-run-apache/
The disable one by one
http://www.sitepoint.com/unblock-port-80-on-windows-run-apache/
Wednesday, November 7, 2012
How to solve error "The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF"?
There are two ways to sovle the problem:
1: Add this setting into config file?
<configuration>
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>
</configuration>
2. Call following function first
public static bool setAllowUnsafeHeaderParsing()
{
//Get the assembly that contains the internal class
Assembly aNetAssembly = Assembly.GetAssembly(typeof(System.Net.Configuration.SettingsSection));
if (aNetAssembly != null)
{
//Use the assembly in order to get the internal type for the internal class
Type aSettingsType = aNetAssembly.GetType("System.Net.Configuration.SettingsSectionInternal");
if (aSettingsType != null)
{
//Use the internal static property to get an instance of the internal settings class.
//If the static instance isn't created allready the property will create it for us.
object anInstance = aSettingsType.InvokeMember("Section",
BindingFlags.Static | BindingFlags.GetProperty | BindingFlags.NonPublic, null, null, new object[] { });
if (anInstance != null)
{
//Locate the private bool field that tells the framework is unsafe header parsing should be allowed or not
FieldInfo aUseUnsafeHeaderParsing = aSettingsType.GetField("useUnsafeHeaderParsing", BindingFlags.NonPublic | BindingFlags.Instance);
if (aUseUnsafeHeaderParsing != null)
{
aUseUnsafeHeaderParsing.SetValue(anInstance, true);
return true;
}
}
}
}
return false;
}
1: Add this setting into config file?
<configuration>
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>
</configuration>
2. Call following function first
public static bool setAllowUnsafeHeaderParsing()
{
//Get the assembly that contains the internal class
Assembly aNetAssembly = Assembly.GetAssembly(typeof(System.Net.Configuration.SettingsSection));
if (aNetAssembly != null)
{
//Use the assembly in order to get the internal type for the internal class
Type aSettingsType = aNetAssembly.GetType("System.Net.Configuration.SettingsSectionInternal");
if (aSettingsType != null)
{
//Use the internal static property to get an instance of the internal settings class.
//If the static instance isn't created allready the property will create it for us.
object anInstance = aSettingsType.InvokeMember("Section",
BindingFlags.Static | BindingFlags.GetProperty | BindingFlags.NonPublic, null, null, new object[] { });
if (anInstance != null)
{
//Locate the private bool field that tells the framework is unsafe header parsing should be allowed or not
FieldInfo aUseUnsafeHeaderParsing = aSettingsType.GetField("useUnsafeHeaderParsing", BindingFlags.NonPublic | BindingFlags.Instance);
if (aUseUnsafeHeaderParsing != null)
{
aUseUnsafeHeaderParsing.SetValue(anInstance, true);
return true;
}
}
}
}
return false;
}
How to install SOAP::Lite module into OTRS on Windows IIS server?
Run Perl\bin\ppm.bat as administrator
Search SOAP and install it
How to set up SOAP / Web service user for OTRS?
- Login into your existing OTRS Installation as Admin
- in the Menu under “Admin”->”Sysconfig” set Group to “Framework” and click “show”
- In the list of subgroups click “Core::SOAP”
- Check the boxes for SOAP::User: and SOAP::Password: and enter the values you like
- click update
http://www.iniy.org/?p=20
- in the Menu under “Admin”->”Sysconfig” set Group to “Framework” and click “show”
- In the list of subgroups click “Core::SOAP”
- Check the boxes for SOAP::User: and SOAP::Password: and enter the values you like
- click update
http://www.iniy.org/?p=20
Where is database connection setting in OTRS?
Under folder:
\OTRS\Kernel
File name is config.pm
Reference:
http://doc.otrs.org/2.1/en/html/c1154.html
\OTRS\Kernel
File name is config.pm
Reference:
http://doc.otrs.org/2.1/en/html/c1154.html
How to get download file length by WebClient?
byte[] buffer;
var client = new WebClient();
buffer = client.DownloadData("http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js");
Stream strm = new MemoryStream(buffer);
var fileLength = strm.Length;
var client = new WebClient();
buffer = client.DownloadData("http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js");
Stream strm = new MemoryStream(buffer);
var fileLength = strm.Length;
Tuesday, November 6, 2012
Monday, November 5, 2012
How to install PHP on Windows 7?
1. Download php for windows
2. Turn on CGI
3. Add Module Mapping for PHP
http://www.hauser-wenz.de/s9y/index.php?/archives/280-Installing-PHP-on-Windows-7.html
Subscribe to:
Posts (Atom)