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

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesDNN MVC Executing action by AJAXDNN MVC Executing action by AJAX
Previous
 
Next
New Post
3/16/2016 10:27 AM
 

Hi,

Another problem occured in my DNN MVC development journey. I am wondering whether this is a bug/missing feature of I've made a mistake. 
I will try to explain the problem and my attempts to resolve/bypass it. 

What do I want to achieve?
I want to execute an action in my controller by calling an AJAX post. So far it works.
However, when I try to return some variables to my View, it doesn't only return the variables. It adds an whole HTML-source to the response.

My controller
My method returns an ActionResult (I tried JsonResult and something different: HttpResponseMessage)
The program itself is working and does return the json-message.


My view
The View below isn't my final View, but's meant to test.

Does anybody know why it is returning an whole HTML-source instead of just the specified variables? Is this a bug, or something I am able to fix? Thank you very much for your time.

 
New Post
5/8/2017 4:00 PM
 
I know this thread is old. But I was running into this issue and was finally able to resolve it. I thought I'd share my solution in case anyone else is still having this problem.

For me, I was missing a RouteConfig.cs in my project.

Here is the code I used (sorry for the formatting, I am unable to load the full reply page, so I'm stuck with the quick reply box and don't know the formatting syntax):
using DotNetNuke.Web.Mvc.Routing;

namespace ModuleNamespace
{
public class RouteConfig : IMvcRouteMapper
{
public void RegisterRoutes(IMapRoute mapRouteManager)
{
mapRouteManager.MapRoute("ModuleName", "ModuleName", "{controller}/{action}", new[]
{"ModuleNamespace.Controllers"});
}
}
}


Once I added that file in, I no longer got the extra HTML in my responses. Without the mapping, I was getting my JSON and the page load source, which was causing some database connection issues for me.

Hope this helps!
 
New Post
3/27/2019 1:18 PM
 
is there anything special you have to do after you create a routeconfig.cs?? ... i followed your code and am still getting the entire page returned
 
New Post
4/4/2019 7:42 AM
 
So i used this line in the ajax response but i feel like its super hacky, does can anyone help!?

...
success: function (responseWithDNNdingleberries) {
var jsonResponse = responseWithDNNdingleberries.substring(0, responseWithDNNdingleberries.indexOf(""));
var data = JSON.parse(jsonResponse);
...
}
 
New Post
4/4/2019 9:23 AM
 
Stephen Louks wrote:
So i used this line in the ajax response but i feel like its super hacky, does can anyone help!?

...
success: function (responseWithDNNdingleberries) {
var jsonResponse = responseWithDNNdingleberries.substring(0, responseWithDNNdingleberries.indexOf(" < ! DOCTYPE html>"));
var data = JSON.parse(jsonResponse);
...
}

 

 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesDNN MVC Executing action by AJAXDNN MVC Executing action by AJAX


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