Hello,
Going through some growing pains porting my ASP.Net MVC over to DNN.
I've created a DAL2 MVC module from Chris Hammond's template. Added in and tested a small JavaScript file. Next step is to get Ajax working and then plug in the data layer from a DNN 6 module I already have and just start using it. Simple process and I'm embarrassed that in this environment, making that 'easy' Ajax call isn't panning out.
I can call the checkbox and other items on the page and manipulate them, so that's working. I can go to Edit | Settings, set a break point, hit a break point in the SettingsController.cs file. I can do the same for ItemController.
I get a 404 when trying a simple Ajax call. Somehow it's a routing or a URL error but I'm missing it. On regular ASP.Net, what I'm doing with Ajax works. With DNN I'm hitting speed bumps all over the place.
Appreciate any help, if there's anything I've not provided, let me know and I'll upload it.
Here is the ASCX file setting up the javascript registration:
<%@ Control Language="C#" AutoEventWireup="false" CodeBehind="TestForm2.ascx.cs" Inherits="Durthaler.Modules.FirstDALMVC.TestForm2" %>
<%@ Register TagPrefix="dnn" Namespace="DotNetNuke.Web.Client.ClientResourceManagement" Assembly="DotNetNuke.Web.Client" %>
<dnn:DnnJsInclude runat="server" FilePath="/DesktopModules/MVC/FirstDALMVC/resources/javascript/settings.js" />
Here's my JavaScript
// JavaScript source code
$(function () {
$.ajax({
url: 'Item/Test' (have varied the url, using the full path, etc. all I ever get is the error alert below, never do hit success)
, type: 'POST'
, cache: false
//, data: {
// 'testData': 10
//}
//, dataType: 'json'
, success: function (data) {
got to success');
},
error: function (request, error) {
ein, Tod'); <-- Only getting here, never to success.
}
});
});
ItemController.cs file
namespace Durthaler.Modules.FirstDALMVC.Controllers
{
[DnnHandleError]
public class ItemController : DnnController
{
[HttpPost]
public ActionResult Test()
{
return null;
}
public ActionResult Delete(int itemId)
{
ItemManager.Instance.DeleteItem(itemId, ModuleContext.ModuleId);
return RedirectToDefaultRoute();
}