Wcf doesnt have an HttpContext. if you want to store data in a user session all you need to do is set teh InstanceContextMode of the service class to Session, then use a channel that supports sessions such as wsHttpBinding. What this causes is a new instnace of teh service to be created per session. By default a new instance of the service is created with each and every call. So if a new instance of the service is created per session, then that means that all of the local varaibles in the service are implicitly per session. So you can just store the values there.
You can get access to HttpContext.Current by enabling AspNetCompatibility, preferably via configuration:
You can even enforce AspNetCompatibility by decorating your service class with an additional attribute
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
This error is because of x64 bit machine. To fix this error, Right-click the project node in Solution Explorer and click Properties. Click on Configuration Properties.Click on Configuration Manager. click on New under Platform and change it to x64 and see if it fixes the problem. If it doesn’t then change the platform to x86.
To create and deploy the WCF Service as the Windows Service in step by step. The following article describe about.
- Steps to Create Windows Service using WCF
- Steps to Deploy Windows Service using installutil.exe
Steps to Create Windows Service using WCF
- Create new project using VS2012, Select File > New Project from the Menu.
- Select Windows Service template from New Project dialog.
- Right click on designer and select Property and set ServiceName and Name
- Drag an EventLog component to the designer, from the Components section of the Toolbox.
- Press F5 and use the below code.
eventLog1.Source = "WSMessage";
eventLog1.Log = "NewWSLog";
protected override void OnStart(string args)
string str = "Service Start at :" + DateTime.Now.ToString();
protected override void OnStop()
string str = "Service Stopped at :" + DateTime.Now.ToString();
Now Windows service is ready and it is ready to write message to Event handler while start and stop event is triggered.
Steps to Deploy Windows Service using installutil.exe
- Right-click Service1.cs and select View Designer from Solution Explorer
- Right-click, and then click Add Installer in View Designer Screen. The two installers is added to your project inside ProjectInstaller.cs screen.
- Right click on serviceInstaller1 from ProjectInstaller.cs and make sure the Service Name property is set to MyFirstWindowsService and Start Type property is set to Automatic.
- Right click on serviceProcessInstaller1 from ProjectInstaller.cs and Set the Account property to LocalSystem. This will cause the service to be installed and to run on a local service account.
Steps to install
- Open the Developer Visual Command Prompt in Administrator mode
- Open the Control panel and check the ‘MyNewService’ is started else start service.
This String.Format method accepts a format string followed by one to many variables that are to be formatted.
"Call my function", "MyFunction()", true);
Onpage load event
If you are binding the data in page load You no need to assign the datasource again else you should assign the datasource here
Click here for more Gridview Paging
RowCreated event fires when the html-controls for a row are created. For example the controls you specify in templates, such as a text box or a dropdownlist. Data binding has not yet taken place.
RowDataBound event fires when the data row is bound to the data of the GridView. Can be used to do data manipulation based on the custom condition, or do logical function based on the data for each GridViewRow or to alter the UI of each row based on the condition.
RowCommand event fires when a button is clicked from inside the GridView Row. Can be used to Select,Insert,Update, Delete, or to do custom operation inside the GridViewRow