Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
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.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 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

16 Experts available now in Live!

Get 1:1 Help Now