- An application pool is a group of one or more URLs that are served by a worker process or set of worker processes. Any Web directory or virtual directory can be assigned to an application pool. Every application within an application pool shares the same worker process.isolatation:Application pools allow you to isolate your applications from one another, even if they are running on the same server. This way, if there is an error in one app, it won't take down other applications.Additionally, applications pools allow you to separate different apps which require different levels of security, reliability, and availability.Main Point to Remember:1. Isolation of Different Web Application
2. Individual worker process for different web application
3. More reliably web application
4. Better Performance
Translate
Wednesday, 30 July 2014
Friday, 25 July 2014
Wednesday, 23 July 2014
Calling a static "page method" from Javascript using MS AJAX
This is designed for v1.0.61025.0 of AJAXExtensionsToolbox.dll
Enable Page Methods on your ScriptManager
Set the EnablePageMethods attribute to true
<asp:ScriptManager ID="ScriptManager1"
EnablePageMethods="true"
EnablePartialRendering="true" runat="server" />
Mark your method as static and give it the WebMethod attribute
The method has to be declared static. It must also be marked with the WebMethod attribute. You'll probably find that you need to include System.Web.Services
using System.Web.Services;
[WebMethod]
public static string MyMethod(string name)
{
return "Hello " + name;
}
Call it from Javascript
To call the method from javascript you need to append PageMethods. to the front of the method name.
<script>
function test() {
alert(PageMethods.MyMethod("Gksamy"));
}
</script>
Enable Page Methods on your ScriptManager
Set the EnablePageMethods attribute to true
<asp:ScriptManager ID="ScriptManager1"
EnablePageMethods="true"
EnablePartialRendering="true" runat="server" />
Mark your method as static and give it the WebMethod attribute
The method has to be declared static. It must also be marked with the WebMethod attribute. You'll probably find that you need to include System.Web.Services
using System.Web.Services;
[WebMethod]
public static string MyMethod(string name)
{
return "Hello " + name;
}
Call it from Javascript
To call the method from javascript you need to append PageMethods. to the front of the method name.
<script>
function test() {
alert(PageMethods.MyMethod("Gksamy"));
}
</script>
Thursday, 17 July 2014
Passing values from C# Code Behind to JavaScript.
You can use var variable name = "<%=this.variable%>" to get value from aspx.cs. Variable must be public , protected in aspx.cs file.
For example, you can use: var date=”<%=DateTime.Now%>”; to get the server time.
For example, you can use: var date=”<%=DateTime.Now%>”; to get the server time.
Wednesday, 16 July 2014
Sunday, 13 July 2014
MVC4 Registration form with Client and Server Side Validation
http://www.dotnet-tricks.com/Tutorial/mvc/H1VF301212-MVC4-Registration-form-with-Client-and-Server-Side-Validation.html
http://www.c-sharpcorner.com/UploadFile/c25b6d/creating-the-registration-form-in-Asp-Net-mvc-3-using-razor/
http://www.c-sharpcorner.com/UploadFile/b19d5a/custom-user-login-and-registration-page-in-Asp-Net-mvc3-with-razor-and-entity-framework/
http://www.codeproject.com/Articles/639695/Getting-Started-with-Razor-View-Engine-in-MVC
MVC 2
http://www.codeproject.com/Articles/207797/Learn-MVC-Model-View-Controller-step-by-step-in-7
http://www.c-sharpcorner.com/UploadFile/c25b6d/creating-the-registration-form-in-Asp-Net-mvc-3-using-razor/
http://www.c-sharpcorner.com/UploadFile/b19d5a/custom-user-login-and-registration-page-in-Asp-Net-mvc3-with-razor-and-entity-framework/
http://www.codeproject.com/Articles/639695/Getting-Started-with-Razor-View-Engine-in-MVC
MVC 2
http://www.codeproject.com/Articles/207797/Learn-MVC-Model-View-Controller-step-by-step-in-7
Friday, 11 July 2014
ViewData vs ViewBag vs TempData vs Session
ViewData
- ViewData is a dictionary object that is derived from ViewDataDictionary class.
- public ViewDataDictionary ViewData { get; set; }
- ViewData is a property of ControllerBase class.
- ViewData is used to pass data from controller to corresponding view.
- It’s life lies only during the current request.
- If redirection occurs then it’s value becomes null.
- It’s required typecasting for getting data and check for null values to avoid error.
ViewBag
- ViewBag is a dynamic property that takes advantage of the new dynamic features in C# 4.0.
- Basically it is a wrapper around the ViewData and also used to pass data from controller to corresponding view.
- public Object ViewBag { get; }
- ViewBag is a property of ControllerBase class.
- It’s life also lies only during the current request.
- If redirection occurs then it’s value becomes null.
- It doesn’t required typecasting for getting data.
TempData
- TempData is a dictionary object that is derived from TempDataDictionary class and stored in short lives session.
- public TempDataDictionary TempData { get; set; }
- TempData is a property of ControllerBase class.
- TempData is used to pass data from current request to subsequent request (means redirecting from one page to another).
- It’s life is very short and lies only till the target view is fully loaded.
- It’s required typecasting for getting data and check for null values to avoid error.
- It is used to store only one time messages like error messages, validation messages. To persist data with TempData refer this article: Persisting Data with TempData
Session
- Session is an object that is derived from HttpSessionState class.
- public HttpSessionState Session { get; }
- Session is a property of HttpContext class.
- Session is also used to pass data within the ASP.NET MVC application and Unlike TempData, it never expires.
- Session is valid for all requests, not for a single redirect.
- It’s also required typecasting for getting data and check for null values to avoid error.
Thursday, 10 July 2014
How to detect browser close when browser [X] is clicked ? or Window Close Event of Browser
aspx page:
<script type="text/javascript" language="javascript">
window.onbeforeunload = closeit;
function closeit() {
var closeEvent = false;
//alert(event.clientY);
if (event.clientY < 0)
closeEvent = true;
if ((closeEvent)) {
document.getElementById('btnClose').click();
}
}
</script>
<table>
<tr>
<td>
<asp:Button ID="btnClose" runat="server" OnClick="closebrowser"
Style="display: none" />
</td>
</tr>
</table>
c# page:
public void closebrowser(object sender, EventArgs e)
{
try
{
// do something
}
catch (Exception ex)
{
throw ex;
}
}
<script type="text/javascript" language="javascript">
window.onbeforeunload = closeit;
function closeit() {
var closeEvent = false;
//alert(event.clientY);
if (event.clientY < 0)
closeEvent = true;
if ((closeEvent)) {
document.getElementById('btnClose').click();
}
}
</script>
<table>
<tr>
<td>
<asp:Button ID="btnClose" runat="server" OnClick="closebrowser"
Style="display: none" />
</td>
</tr>
</table>
c# page:
public void closebrowser(object sender, EventArgs e)
{
try
{
// do something
}
catch (Exception ex)
{
throw ex;
}
}
Thursday, 3 July 2014
optional and Named parameters: C#
Program that uses optional parameters: C#
using System;
class Program
{
static void Main()
{
// Omit the optional parameters.
Method();
// Omit second optional parameter.
Method(4);
// You can't omit the first but keep the second.
// Method("Dot");
// Classic calling syntax.
Method(4, "Dot");
// Specify one named parameter.
Method(name: "Sam");
// Specify both named parameters.
Method(value: 5, name: "Allen");
}
static void Method(int value = 1, string name = "Perl")
{
Console.WriteLine("value = {0}, name = {1}", value, name);
}
}
Output
value = 1, name = Perl
value = 4, name = Perl
value = 4, name = Dot
value = 1, name = Sam
value = 5, name = Allen
using System;
class Program
{
static void Main()
{
// Omit the optional parameters.
Method();
// Omit second optional parameter.
Method(4);
// You can't omit the first but keep the second.
// Method("Dot");
// Classic calling syntax.
Method(4, "Dot");
// Specify one named parameter.
Method(name: "Sam");
// Specify both named parameters.
Method(value: 5, name: "Allen");
}
static void Method(int value = 1, string name = "Perl")
{
Console.WriteLine("value = {0}, name = {1}", value, name);
}
}
Output
value = 1, name = Perl
value = 4, name = Perl
value = 4, name = Dot
value = 1, name = Sam
value = 5, name = Allen
Subscribe to:
Posts (Atom)