Before you call for service;
svc.RequestSoapContext.Security.Tokens.Add(new UsernameToken(UserName, Password, PasswordOption.SendPlainText));
svc.RequestSoapContext.Security.Tokens.Add(new UsernameToken(UserName, Password, PasswordOption.SendPlainText));
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" throwExceptions="true" internalLogFile="c:\nlog.txt" internalLogLevel="Trace" >
protected override System.Net.WebRequest GetWebRequest(Uri uri) { string pass = "pass" + ":" + "****"; var key = Convert.ToBase64String(new System.Text.ASCIIEncoding().GetBytes(pass)); var basicKey= "Basic " + key; var getWebRequest = base.GetWebRequest(uri); getWebRequest.Headers.Add("authorization", basicKey); return getWebRequest; }
//Input Argument WF IDictionary<string, object> inputs = new Dictionary<string, object> { {"Person1", new Person{ Name="Tom", Age=26}} }; //Output Argument IDictionary<string,object> outputs=WorkflowInvoker.Invoke(new Activity1(),inputs); Console.WriteLine(outputs["Accepted"].ToString());
Open the Global.asax file then write code;
void ErrorLog_Filtering(object sender, ExceptionFilterEventArgs e) { if (e.Exception.GetBaseException() is FileNotFoundException || e.Exception.GetBaseException() is HttpException) e.Dismiss(); }
class Program { static void Main(string[] args) { try { throw new Exception("Expection"); } catch (Exception ex) { ex.SendErrorEmail(); } } } public static class MyExtension { public static void SendErrorEmail(this Exception ex) { //Write your send mail code //.... smtpClient.Send(mailMessage); } }
In SqlServer right click on the database,select Database Properties.Then Go to Files section. Click the Autogrowth, select Unresticted File Growth.
public class Customer { public string Name{ get; set;} public string Surname{ get; set;} public int ID{ get; set;} }
public class Person { public string FullName{ get; set;} public int Age { get; set; } }Auto Mapper Class;
public class CustomerToPersonConverter:ITypeConverter<Customer,Person> { public Person Convert(ResolutionContext context) { Person person = new Person(); Customer customer = context.SourceValue as Customer; person.Age = customer.ID + 15; person.FullName = customer.Name + " " + customer.Surname; return person; } }In Page_Load;
protected void Page_Load(object sender, EventArgs e) { Customer customer = new Customer() { ID=1, Name="Engin", Surname="Dotnet" };//Set The Map - #1 Mapper.CreateMap<Customer, Person>().ForMember(per => per.FullName, mus => mus.MapFrom(opt => opt.Name + " " + opt.Surname)).ForMember(per => per.Age, mus => mus.MapFrom(opt => opt.ID + 14)); //Set The Map - #2 Mapper.CreateMap<Customer, Person>().ConvertUsing<CustomerToPersonConverter>(); //Set The Map - #3 Mapper.CreateMap<Customer, Person>().ConvertUsing(cus => { Person per = new Person(); per.Age = customer.ID + 15; per.FullName = cus.Name + " " + cus.Surname; return per; }); ///Then Use Person person = Mapper.Map<Customer, Person>(customer); Response.Write(person.Age + " " + person.FullName); }
protected void Page_Load(object sender, EventArgs e) { try { SQLiteConnection conn = new SQLiteConnection("Data Source=" + Server.MapPath("sqlitedb.db") + ";Version=3;"); SQLiteDataAdapter adap = new SQLiteDataAdapter("select * from table", conn); conn.Open(); DataTable dt = new DataTable(); adap.Fill(dt); grd.DataSource = dt; grd.DataBind(); conn.Close(); } catch (Exception ex) { Response.Write(ex.Message); }
Factory="System.ServiceModel.Activation.WebServiceHostFactory"
Then;Add WebGet Attribute WCF Method
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();
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
<globalization fileEncoding="iso-8859-9" requestEncoding="utf-8" responseEncoding="utf-8" culture="tr-TR" uiCulture="tr-TR" />
HttpContext.Current.Request.IsSecureConnection
or
Request.ServerVariables["SERVER_PROTOCOL"];
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