NopCommerce 3.3 Add link for custom Plugin Action in ProductTemplate.Simple.cshtml, unable to find Controller and model of same view - asp.net-mvc-4

We had created a Custom Plugin , The Nop.Web Site provided to us by our Client did not had Controller, models, Nop.Web.cs project. Initially We did not require to access much of the Nop.Web project as everything was managed through Plugin
But now there was need to add a custom Link on the ProductTemplate.Simple.cshtml view of Nop.Web/Themes/Motion/View/Catalog
Link was to add the product into a custom registry Cart.
The link access ActionResult from "Catalog" Controller supposed to be in Nop.Web Controller.
I need to pass it our Custom Plugin Controller and Action Result. But it throws error as it cannot find the controller nor "Our Custom Plugin Controller" neither the "Catalog" controller.
Can anyone suggest us solution to achieve this in better way.
Any help will be appreciated.

Can you open your controller action in a separate window? Are you sure it's valid?
Have you looked at widgets which are supported by nopCommerce? This way you won't need to edit the cshtml file

Related

Umbraco with MVC Controller

I am working on MVC and i started learning Umbraco, I didn't get how to bind the umbraco page with mvc controller get method to show the database values. can anyone suggest any url or video?
Thansk...
What you're looking for is Umbraco route hijacking.
You can read about it here.
https://our.umbraco.org/documentation/reference/routing/custom-controllers
It's easiest to demonstrate with an example : let's say you have a Document Type called 'Home'. You can create a custom locally declared controller in your MVC web project called 'HomeController' and ensure that it inherits from Umbraco.Web.Mvc.RenderMvcController and now all pages that are of document type 'Home' will be routed through your custom controller! Pretty easy right :-) OK so let's see how we can extend this concept. In order for you to run some code in your controller you'll need to override the Index Action.
So, basically, you "simply" need to create a controller named after your document type, so for example, a document type with the name "TextPage" would need a controller called "TextPageController". Now, if you read through the documentation, you'll find that your "TextPageController" will need to inherit from the RenderMvcController. Here's an example how to achieve this.
public class TextPageController : RenderMvcController
{
public ActionResult Index()
{
return View("~/Views/TextPage.cshtml");
}
}
This forum link may help you:
https://our.umbraco.org/forum/developers/razor/38242-Umbraco-MVC4111-Surface-controller-using-an-AJAX-form

Sitefinity Feather custom action form

I've got the following problem: in Sitefinity (9.1, Feather) I need a form, which can call 3rd party API (Mandrill) once submitted.
As far as I understand, I need some kind of custom widget or something.
Any help would be very appreciated.
Thanks
I would start here. You don't necessarily have to create a separate class library for creating the custom Feather widget (you can just put it in the SitefinityWebApp web project), but you can if you like. With Feather/MVC widgets you basically get a Controller and View, with an optional Model class to play with too.
In your scenario, you'd probably have a Controller with two actions: Display the form, and handling the form submission. In your form submit action you'd then call Mandrill to submit the data (or do whatever it is you need to do). In your Controller you're in C# purely, so you can do whatever you like there.

Cannot Navigate using Controller/Action in Navigation Bar

I am working in an ASP.NET MVC 4 project. I did not create this project, but whomever did, fixed it so that I cannot put the ControllerName/ActionMethod in the navigation bar to navigate to any page/view in the project (including any new view/page that I create). Given that I cannot navigate to new views/pages that I create myself, I am assuming that there must be some sort of global setting to prevent this, but I am new to MVC and can't figure out where to look or what to look for. Any help with this would be greatly appreciated!!!!
I was able to figure this out (not completely, but enough to make it work). I needed to add
[Authorize] above the public class Controller. Hope this helps someone else!

How does jQuery's FileUpload's Backload connect with UploadHandler?

I got jQuery File Upload along with Backload up and running in Visual Studio, straight out of NuGet. The demo works just fine, I can upload files. I'm using the default configuration.
http://blueimp.github.io/jQuery-File-Upload/basic.html
https://github.com/blackcity/Backload
BackloadDemo/Index.cshtml has the following form:
<form id="fileupload"
action="/Backload/UploadHandler"
method="POST"
enctype="multipart/form-data">
It works, but I can't figure out how it works. Where does /Backload/UploadHandler link to? I cannot find any reference of this 'UploadHandler'.
I was trying to figure the same thing out and I have found the answer.
If you check the Backload.dll you will see a namespace of Backload.Controllers with a class named BackloadController.
This is the controller that is picking up and handling the request. ASP.Net uses reflection to gather all classes that end with Controller and inherit from Controller. The reason you can't see this controller in the Controllers folder is because they are embedding the implementation inside the Backload.dll
From your second link:
Backload is a professional, full featured file upload controller and handler (server side) for ASP.NET
So the request to /Backload/UploadHandler either gets intercepted by a handler or picked up by a controller.
If your actual question is "How do I incorporate Backload in my project", then refer to their documentation or show relevant code and explain what you did, what you expect to happen and what actually happens.

Yii generate errors from parent controller

I just started using Yii, coming from Codeigniter (CI). I'm trying to set up a situation where the application will check a users credentials before they can even access the site. In CI, I would create a parent controller, put my checks in there, and then inherit that parent controller. I've been trying to do the same thing with Yii, but with no luck.
I first created an init() method (for some reason I can't put the code in a __construct() method). I then perform my check, which works fine. I can throw a new CHttpException, but that looks ugly. How do I use Yii's built in error handling to accomplish what I want to do?
For simple login rules you should just implement the 'accessControl' filters from Yii see Yii documentation on authorizations.
Another way would be to throw the Exception like you already did, and write custom Http error views, place it in the yerfolder/protected/views/system/ (see the yii/framework/views directory for examples)
I solved this by sending the error to the site/error view and then calling Yii::app()->end() to keep the child controllers from loading.