Solved

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

Posted on 2015-02-01
2
178 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 36

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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

713 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