Solved

Convert C# solution to a function that can be called by MVC

Posted on 2015-02-01
2
168 Views
Last Modified: 2015-02-01
I have a c# console solution. The solution runs and generates a report in the form of a datatable.
I use a around 10 different classes and 1 dll within the solution.

I would like to convert the solution to a funtion that can be called by ASP.NET MVC with a parameter and return the content of the datatable. Is this possible? If so, how can I do it?
0
Comment
Question by:esak2000
2 Comments
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 250 total points
ID: 40582741
Well, it's .NET, so you could potentially just add a reference to the console application from your MVC application, and then use it the same way you would a DLL. If you really want to, you could convert it to a library.
0
 
LVL 35

Assisted Solution

by:Miguel Oz
Miguel Oz earned 250 total points
ID: 40582845
Two alternatives:
A1. Call your console app from MVC using Process.Start. check the sample method LaunchCommandLineApp for further details.
Notice that your web site (thus your console app) runs under a restricted user account, make sure you have the appropriate security permissions.
A2. Refactor the classes/dll of the console app into a library, then in that library implement a public static method that can be called by both your console app and your MVC project. In other words you are sharing the common logic between the 2 apps. the advantage is you do not have to worry about security permissions.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now