Solved

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

Posted on 2015-02-01
2
176 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 75

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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

831 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