Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...DNN MVC Custom Module - use parameter for actionresultDNN MVC Custom Module - use parameter for actionresult
Previous
 
Next
New Post
3/24/2018 3:23 PM
 

Hey,

I’m looking for a way to retrieve items for a specified ID by creating an actionresult with an ID as parameter. I know that this is possible with ASP.NET MVC by using {url}?id={number}. Does anyone has suggestions? 

P.S. The module is currently showing on a dnn-page with other modules.

 
New Post
3/25/2018 1:56 PM
 
Hello

I think I can help you out but I have a few clarification questions before I provide the best answer to your problem:

* Is there a business need to do this in the [ActionFilter]?
* Have you tried creating an additional Action Method on your controller to handle this situation?

Based on the scenario described above it appears your best option is creating a action method or perhaps a web API method on your controller that returns JSON and then specify the route.

Please provide a little bit more detail about your problem and what you are trying to solve and I can provide a better answer and more recommendations
 
New Post
3/25/2018 6:55 PM
 
Hello,

Thanks for your reply!

1. There is no need to do this in the actionfilter
2. No, I didn’t

Currently I’m trying to pass it as a parameter to the actionresult like this:

public ActionResult Index(int categoryId=-1)
{
// Retrieve product list of a category
List products = db.Products.Where(p=>p.categoryId == categoryId).ToList();

// Return view
return view(products)

If you have a solution, please tell me in detail (code would be appreciated)


 
New Post
3/26/2018 4:47 AM
Accepted Answer 
I misread your originally question, my mistake. I'm understanding what you are trying to do. (sorry about that)

The code you provided looks correct to me assuming you have everything else working. Depending where you are trying to navigate from there are a few different ways to solve this problem. I am going to make the assumption you are trying to perform a new actionresult from the razor.

Try:

'@Url.Action("Controller", "Action")?categoryId=4'

When accessing other controller methods you really should use the UrlHelper object because it will generate the correct route that will include the module instance ID so your route won't conflict with other modules on the page.

Hope this helps, if this doesn't make sense I can try clarifying more
 
New Post
3/26/2018 6:14 PM
 
Ah that was the answer I was looking for. Thanks!
 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...DNN MVC Custom Module - use parameter for actionresultDNN MVC Custom Module - use parameter for actionresult


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out