0

We have a sitefinity Customer Portal. Now we need to add MVC pages to it. I understand how to add a page, and how to drag e.g. a list to the page's content. But I don't understand how I can create a controller and other c# code to populate the list and do other custom things. We cannot open the project in Visual Studio, and we have no access to the existing code.

David Shochet
  • 5,035
  • 11
  • 57
  • 105

2 Answers2

0

You need to get access to the code then, controllers\models need to be compiled. You can get away with a lot directly in a cshtml file though which DOESN'T need to be compiled.

Could you download a new blank SF project that's on your version and start from scratch pointed at your DB? Copy over /App_Data and /ResourcePackages to the new project and just run it. Should work fine, but any page that has a custom widget on it that uses custom code would tank. Sorry I'm just not sure why you don't have the code. Could use JustDecompile to retrieve the actual code for custom widgets too I suppose.

Steve McNiven-Scott
  • 1,770
  • 2
  • 15
  • 29
  • Thank you for your answer. It is not quite clear to me though, as I have no access to the existing code. I just need to add my own views with the controllers and models. I guess, I could create a new project, but it would not be a part of the existing application. Am I missing something? – David Shochet Feb 18 '20 at 19:47
  • The other thing that you can try is to check if the REST services have been enabled for the public (or request them to be turned on) and then use a FE technology like Angular or React to build your functionality – Amit Joshi Feb 19 '20 at 02:11
0

First of all, you must sure your project run success on your local. You can check it by login to back end page.

Then you can create the MVC component like this: (you should create all of this in root/MVC folder)

Create controller first:

[ControllerToolboxItem(Name = "ImportCSV", Title = "ImportCSV", SectionName = "ImportCSV")]
public class ImportCSVController : Controller
{
    // GET: ImportCSV
    public ActionResult Index()
    {
        return View();
    }
}

SectionName is title of content group for you custom Title is the title of component Name is used for code behind

Then you can create the views to show in page: (you have to create the views in MVC/Views/ImportCSV, sitefinity will recognize folder name to map in BE)

<h2>Upload File</h2>
<div class="form-group">
<input type="file" id="dataFile" name="upload" />
</div>
<div class="form-group">
    <a onclick="upload()" class="button" id="btnupload">Upload</a>
</div>
ThinhLe
  • 409
  • 1
  • 3
  • 12