Factory="System.ServiceModel.Activation.WebServiceHostFactory"Then;Add WebGet Attribute WCF Method
Monday, October 10, 2011
Change WCF Service From Soap To Rest
In Service.svc change Factory Property;
Custom UserName-Password Validator in WCF Service
1-
public class MyCustomValidator : UserNamePasswordValidator
{
public override void Validate(string userName, string password)
{
//get from db or anywhere if (userName != "engin" && password != "dotnet") { throw new SecurityTokenException("Validation failed."); } } }
2-In WebConfig
<bindings> <basicHttpBinding> <binding name="basicBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> <security mode="TransportCredentialOnly"> <transport clientCredentialType="Basic">transport> security> binding> basicHttpBinding> bindings> <behaviors> <serviceBehaviors> <behavior name="mexBeh"> <serviceMetadata httpGetEnabled="true" /> <serviceCredentials> <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="WcfServiceLibrary2.MyCustomValidator,WcfServiceLibrary2"/> serviceCredentials> behavior> serviceBehaviors> behaviors>3-Finall write your code;WcfUserPassClient svc = new WcfUserPassClient(); svc.ClientCredentials.UserName.UserName = "engin"; svc.ClientCredentials.UserName.Password = "dotnet"; string result = svc.DoWork();
With a single click install or unistall windows service
To Install;
Create a text file and named install.bat. Then type the following code
@ECHO OFF set DOTNETFX2=%SystemRoot%\Microsoft.NET\Framework\v2.0.50727 set PATH=%PATH%;%DOTNETFX2% echo Installing MyService... echo --------------------------------------------------- InstallUtil /i "ServicePath.exe" echo --------------------------------------------------- echo Done. pause
To Unistall;
Create a text file and named uninstall.bat. Then type the following code
@ECHO OFF set DOTNETFX2=%SystemRoot%\Microsoft.NET\Framework\v2.0.50727 set PATH=%PATH%;%DOTNETFX2% echo Installing MyService... echo --------------------------------------------------- InstallUtil /u "ServicePath.exe" echo --------------------------------------------------- echo Done. pause
ASP.NET Language Problem
<globalization fileEncoding="iso-8859-9" requestEncoding="utf-8" responseEncoding="utf-8" culture="tr-TR" uiCulture="tr-TR" />
Is Secure Connection In ASP.NET
HttpContext.Current.Request.IsSecureConnection
or
Request.ServerVariables["SERVER_PROTOCOL"];
Recently Executed Query
SELECT deqs.last_execution_time AS [Time], dest.TEXT AS [Query]FROM sys.dm_exec_query_stats AS deqs CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle)AS destORDER BY deqs.last_execution_time DESC
Database Read Only In SqlServer
ALTER DATABASE dnName SET READ_ONLY
ALTER DATABASE dbName SET READ_WRITE
Subscribe to:
Posts (Atom)