namespace WindowsServiceApp
{
[ServiceContract(CallbackContract = typeof(IWcfServiceCallBack))]
public interface IWcfService
{
[OperationContract]
void getAuth(string auth);
[OperationContract]
double getPrice(string auth);
}
[ServiceContract]
public interface IWcfServiceCallBack
{
[OperationContract(IsOneWay = true)]
void getCallBack(string returnAurth);
}
}
namespace WindowsServiceApp
{
public class WcfService : IWcfService
{
public static string errorMessage = "";
public void getAuth(string auth)
{
WindowsServiceApp.WinService.FormScan formScan = new WinService.FormScan();
}
public double getPrice(string auth)
{
double a = 1;
return a;
}
}
}
namespace WindowsServiceApp
{
public partial class WinService : ServiceBase
{
ServiceHost host;
private static string errorMessage = "";
public WinService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
host = new ServiceHost(typeof(WcfService));
host.Open();
}
protected override void OnStop()
{
host.Close();
}
}
}
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="WindowsServiceApp.WcfServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBindingConfig"
clientBaseAddress="http://localhost:8733/" >
<security mode="None"/>
</binding>
</wsDualHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="WindowsServiceApp.WcfServiceBehavior" name="WindowsServiceApp.WcfService">
<endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBindingConfig" contract="WindowsServiceApp.IWcfService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
Showing posts with label MVC. Show all posts
Showing posts with label MVC. Show all posts
Tuesday, December 1, 2015
WCF Duplex Communication in Windows Service
Wednesday, September 9, 2015
MVC Custom Authetication
public class HomeController : Controller
{
[CustomRole]
public ActionResult Index()
{
return View();
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
public class CustomRole : AuthorizeAttribute
{
protected override bool AuthorizeCore(HttpContextBase context)
{
//Call from db
var a = 3;
if (a==2)
{
return true;
}
else { return false; }
}
}
Subscribe to:
Posts (Atom)