Search code examples
c#asp.netcode-behind

How to call a code behind function in server from a C# app?


I am in a difficult situation and need help again

There is this aspx webpage and its code behind function is done in vb.net, and these files are on a server..

I have to make a C# application (WinForms EXE) that should run on the server and should call two methods in that code-behind file (which are in vb.net)

(I mean that aspx page's, functionality scripts are done in vb.net.. the aspx page calls these functions in response to button clicks in the page etc... I want to call this function from my C# application.. I hope I am clear now.. the vb code files are in server for eg: "utils.vb" contains StartGame() function.. how can I call this StartGame() function from my C# application which runs on the server independently..)

Is there any way to do this? can some one point me in right direction please?

NB: I have to call the StartGame() function NOT from design page, but from my C# EXE, which will run on the server

(just a guess... if I make that vb.net functions into a dll, can it continue to do the web functionality and can be called from my C#.exe? just an idea.. may be I am wrong)


Solution

  • I don't think you can call codebehind functionality from outside of the ASP.net website that they are defined in. If you want to call the same method both in your website and in your c# exe, you'll need to extract that method to a web service. A webservice can be called by anything which has access to HTTP.