开发者

using c# inside an apache python script

开发者 https://www.devze.com 2023-01-10 04:37 出处:网络
I have a c# application that defines a membership provider used in a Asp.Net MVC application. And i have an apache httpd server that does authentication with mod_wsgi.

I have a c# application that defines a membership provider used in a Asp.Net MVC application. And i have an apache httpd server that does authentication with mod_wsgi.

The objective is to share the membership provider between the two, so that the authentication information be the same.

How can i a开发者_运维百科chieve this behaviour ?


Trivially.

  1. Apache serves static content.

  2. Certain URI's will be routed to mod_wsgi to Python.

  3. Python will then execute (via subprocess) a C# program, providing command-line arguments, and reading the standard output response from the C# program.

  4. Python does whatever else is required to serve the web pages.

This presumes your C# application runs at the command line, reads command-line parameters and writes its result to standard output. This is an easy thing to build. It may not be the way it works today, but any program that runs from the command line is trivial to integrate.

Your C# application, BTW, can also be rewritten into Python. It isn't magic. It's just code. Read the code, understand the code, and translate the code. You'll be a lot happier replacing the C# with something simpler.


Several ways:

  1. COM interface (if Windows OS), although this would be a bit slow (make a COM-compatible library, register it with regasm, use it).
  2. Using Gearman (not sure if faster than COM and whether it has Python and C# support, the investigation is up to you) http://gearman.org/
  3. Using the method described by S.Lott
  4. Using SOAP (slow, big)
0

精彩评论

暂无评论...
验证码 换一张
取 消