|
|
asp.net process model
by Satalaj
24. February 2010 07:37
We can configure the Application Pool Recycling in two ways.
1. Reactive application pool process recycling.
2. Proactive application pool process recycling.
Reactive Process Recycling:
It happens when process is not functioning properly or unable to serve requests.
Symptoms: Process deadlocks, access violations, memory leaks, Insufficiant memory and so on, in order to trigger a process recycle.
You can help control the conditions that cause a process restart by using the requestQueueLimit, memoryLimit, and shutdownTimeout configuration attributes.
For more information about these attributes, see the <processModel> Element configuration section of Machine.Config file.
Proactive Process Recycling
Proactive process recycling restarts the worker process periodically even if the process is healthy.
This can be a useful way to prevent denials of service due to conditions the process model is unable to detect.
A process can be restarted after a specific number of requests or after a time-out period has elapsed. You can enable proactive process recycling using the timeout, idleTimeout, and requestLimit configuration attributes. For more information, see the <processModel> Element configuration section of Machine.Config file.
Below are the default settings of Process model found at machine.config file.
<processModel
enable="true"
timeout="Infinite"
idleTimeout="Infinite"
shutdownTimeout="0:00:05"
requestLimit="Infinite"
requestQueueLimit="5000"
restartQueueLimit="10"
memoryLimit="60"
webGarden="false"
cpuMask="0xffffffff"
userName="machine"
password="AutoGenerate"
logLevel="Errors"
clientConnectedCheck="0:00:05"
comAuthenticationLevel="Connect"
comImpersonationLevel="Impersonate"
responseRestartDeadlockInterval="00:09:00"
responseDeadlockInterval="00:03:00"
maxWorkerThreads="20"
maxIoThreads="20"
/>
Satalaj
client server communication
by Satalaj
25. January 2010 03:47
I was wondering to know how two computers can communicate with each other then I came to know its a client and server who are responsible to setup that communication.
Well, client and server both are applications or you can say computer programs.
Server: Its an application which listens on port and serves the request.
Client: It's also an application who sends a request to server on particular port.
Lets take an example of web, where browser (IE, FF) are clients who sends the request to server on port 80.
On server, there are multiple applications who listens on particular port, like IIS service listens on port 80 where SQL server listens on port 1433.
First browser should know the location of server. That's nothing but the IP address of SERVER.
Only one application can listens on port 80 it can be a IIS or Apache. Both applications can't listens on same port. That's why, if we tell the IIS to
listen on port 80 we need to tell Apache to listen on different port like 8080. So when request came to port 80, IIS will serve that request
and when request came to port 8080 Apache will serve that request.
If we are having two IP addresses assigned to the server then for IP address 192.168.1.1 we can tell the IIS to listen on port 80
and for IP address 192.168.1.2 we can tell Apache to listen on port 80. In this case requests coming to IP 192.168.1.1 port 80 will
get served by IIS and requests coming on 192.168.1.2 port 80 will get served by Apache. This is how we can resolve the conflicts.
Lets talk about how Client communicates with server.
E.g.
Suppose, your IE requests a page http://www.google.com/. It will start establishing the communication with http://www.googe.com/.
During this time if you are trying to request another page of http://www.google.com/ it will establish another connection with server.
In first case, client needs to open a port with server lets say 1001 is opened to communicate with server and this port is engaged.
Means communication is not established yet. As 1001 is engaged second request opens next port 1002 with server and start communicating.
Server establishes the communication with port 1001 and responds to client on port 1001, for second request it responds to client
on port 1002.
You can use netstat command from command prompt to see foreign IP address , ports and local IP address, ports.
It also tell us the state of communication whether its established or waiting for server to respond.
TCP smartmirror:1455 bom01s01-in-f86.1e100.net:http CLOSE_WAIT
TCP smartmirror:1495 digsby04.rit.edu:5222 ESTABLISHED
TCP smartmirror:1497 69.46.36.6:http ESTABLISHED
TCP smartmirror:1501 bom01s01-in-f99.1e100.net:http ESTABLISHE
TCP smartmirror:1502 bom01s01-in-f147.1e100.net:http ESTABLISH
Here smartmirror is my local IP and 1497 is my local port who established connection with foreign IP 69.46.36.6 on port http (80)
Conclusion:
When clients talks with server on port, it doesn't mean that clients needs to have port 80 open at his end.
Clients open the available port 1455 at his end and send requests to server on port 80. Server sends a response to client on
client side port 1455.
The detailed list of available port can be see here http://www.iana.org/assignments/port-numbers
There exists 0 to 65535 ports out of these ports, ports ranging from 49152 to 65535 are available for
dynamic or private ports.
I hope you got clear idea of how client communicates with server.
Satalaj
http://www.satalaj.com/
HTTP Error 404 - File or directory not found.
by Satalaj
19. January 2010 05:09
Scenario, you installed the IIS 6.0 and framework 2.0 on windows 2003 operating system. After deploying the web you observed that web is
responding an error with 404.
By default, once you installed the IIS. It want not allow to run ASP.net or web pages or CGI, perl etc.
you need to allow them to fix this error. You need to open IIS 6.0 and find the node called Web services extensions.
In right pen you can allow or prohibit the access to ASP.net 2.0 or CGI.
For more information you can refer below link
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/44f16c37-f727-4244-9813-2289e13dadba.mspx?mfr=true
or you can use support forum at www.iis.net
The default IIS settings will allow you to only see the Static pages.

Satalaj
Page view count
by Satalaj
16. December 2009 08:36
A very common question How to count page visits to my site?
Well, it can be done in many ways. Here, I will shade some lights on simple and better approch.
Using ASp.net server side code.
When browser begins the request, OnBeginRequest event you can count the page views againt that requet.
What if the request is coming from Load Testing tool or any robot? It is simple approch but not good.
It doesn't ensure that the request is coming from browser.
Better approch:
Create a javascript which will execute at client side browser. Once it start requesting the server apply your logi to count the page visit.
This ensures that the request is coming from Browser as script engine inside the browser is making call.
You can see Google analytics and other tools who can be used to tracks the traffice on your site uses JavaScript.
If you planned to create your own, the benifit is you can have this module of tracking something out of box.
Satalaj
iis7 32 bit mode
by Satalaj
15. December 2009 13:04
You can't run 32bit asp.net application on IIS7 running on 64bit mode.
To run your asp.net web application on IIs7 running on 32 bit mode you need to configure you IIS 7.
First you need to open your command prompt and execute below command to configure IIS configuration.
cscript.exe adsutil.vbs set W3SVC/AppPools/Enable32BitAppOnWin64 1
Here 1 refers to true.
Then you need to run aspnet_regIIS -i found under framework v2.0.
If you are still trouble shooting with IIS, post your thread at http://www.iis.net/ you can use your windows live ID to login or create new account.
Here are some useful stuff http://support.microsoft.com/kb/911720
Satalaj
unable to connect to the remote server
by Satalaj
9. November 2009 12:12
Some times our web applications or windows service or windows desktop applications throws "unable to connect to the remote server".
Make sure url or IP address is correct.
solution:
Proxy server Make sure that your not using Proxy server to access internet. If you are using proxy server to access internet,
contact your administrator and get the network credentials, IP address and port. Add those details in you application
to let it use proxy server.
Anti virus: if you are using ESET antivirus, you need to setup rules init to allow your application in / out request on xxxx port number.
symantech: Disable it and then try.
Application: Application is trying to access apache server url. URL maybe case sensitve use correct url.
use command prompt and execute telnet command
Telnet ip_address port_number
and see the response.
gac assembly location
by Satalaj
21. October 2009 12:41
Here are several ways to know the gac locations
Follow this link: http://www.revenmerchantservices.com/ajax/systemwebextensions.html
gac assembly
by Satalaj
21. October 2009 12:40
In this post we will see how to add assembly into GAC or Global assembly cache.
To add assembly into GAC we need sign the assembly with strong name.
You can get the Key pair by opening .Net command prompt and execute SN -k c:\xxxxx.snk
e.g.
Setting environment for using Microsoft Visual Studio 2005 x64 cross tools.
c:\Program Files\Microsoft Visual Studio 8\VC>sn -k c:\xxx.snk
Microsoft (R) .NET Framework Strong Name Utility Version 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
Key pair written to c:\xxx.snk
c:\Program Files\Microsoft Visual Studio 8\VC>
Now, Copy file xxx.snk and paste it into your class library project.
open your assemblyinfo file give the path of newly created strongname keypair.
Compile the project. Now, your assembly is ready to get into GAC.
E.g.
Open assemblyinfo
add below line
[assembly: AssemblyKeyFile("xxx.snk")]
Save your assemblyinfo.cs file.
Compile the project.
Now we will be registering assembly in gac.
Open your .Net command prompt
Use GACUtil -i to install the assembly into gac
c:\Program Files\Microsoft Visual Studio 8\VC>gacutil -i path_Of_your_signed_assembly.
To know path of assembly you can find it under Debug or release folder of your BIN folder.
Now, your all applications can refer this shared assembly.
You can browse your GAC using technique shown here: http://www.revenmerchantservices.com/ajax/systemwebextensions.html
c# convert array to list
by Satalaj
14. October 2009 12:07
Here is simple trick to convert an array into list
e.g.
using System.Collections.Generic;
protected void Button1_Click(object sender, EventArgs e)
{
string[] arrString = { "Satalaj", "More", "ASP", "Net", "C#" };
List<String> lstString = new List<string>();
foreach (string s in arrString)
{
lstString.Add(s);
}
foreach (string s in lstString)
{
Response.Write(s + "<br/>");
}
// Here we have added an array of string collections into lists
}
VB.net code
Protected Sub Button1_Click(sender As Object, e As EventArgs)
Dim arrString As String() = {"Satalaj", "More", "ASP", "Net", "C#"}
Dim lstString As List(Of [String]) = New List(Of String)()
For Each s As String In arrString
lstString.Add(s)
Next
For Each s As String In lstString
Response.Write(s + "<br/>")
Next
' Here we have added an array of string collections into lists
End Sub
'=======================================================
'Service provided by Telerik (www.telerik.com)
'Conversion powered by NRefactory.
'Built and maintained by Todd Anglin and Telerik
'=======================================================
asp net open new window
by Satalaj
4. October 2009 05:20
Many times we require to open new window as popup with or without toolbar and statusbar.
Here are several ways to acheive it.
1. Open new window without status bar and toolbar
<div>
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="javascript:window.open('http://www.bing.com','Title_of_your_window','statusbar=0,toolbar=0')">
1. Click here to popup window without statusbar and tool bar
</asp:HyperLink>
</div>
2. Open new window with status bar
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="javascript:window.open('http://www.bing.com','Title_of_your_window','statusbar=1,toolbar=1')">
2. Click here to popup window with statusbar and tool bar
</asp:HyperLink>
3. Control height and width of popup window
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="javascript:window.open('http://www.bing.com','Title_of_your_window','statusbar=1,toolbar=1,width=500,height=500')">
3. Click here to popup window with statusbar and tool bar
</asp:HyperLink>
If you want to get the response in new window, you need to add an attribute target="_blank" in your form tag.
When page will do post back it will open response in new window
e.g. <form id="form1" target="_blank" runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>
Above example will always open response in new window.
Using ASP.net Ajax Modal popup extender you can popin your controls as explained here
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ModalPopup/ModalPopup.aspx
Video: http://www.asp.net/learn/ajax-videos/video-85.aspx
Satalaj
|