JQGrid is not configuring in IIS

Oct 15, 2011 at 11:41 AM

Hello all,

I have downloaded the JQGrid for MVC 3 application. Its working fine when i'm running from my local machine. But when i configured to iis its not working. Its not pointing out the exact action that what i called. Following lines are my code that i have written.

@Html.Grid(new GridControl()
        .SetName("grid")
        .SetPageSize(10)
        .SetIsAutoSize(true)
        .SetListUrl(Url.Action("Union", "Home"))    // The URL is not working (404 Error)
        .SetEditUrl(Url.Action("Union", "Home"))
        .SetHeight("232")
        .SetWidth("1000")
        .UseColumns(MVCThreeJQGrid.Models.Columns.UnionColumns)
        .UpdateDefaultPager(pager =>
            pager
                .ShowAdd(true)
                .ShowDel(true, deleteUrl: Url.Action("Union", "Home"))
                .ShowEdit(true)
                .ShowView(true)
        ))

Developer
Oct 15, 2011 at 12:07 PM

Can you tell from the actual HTML of the page what URL it’s actually generating?

Från: VelCodeplex [email removed]
Skickat: den 15 oktober 2011 13:42
Till: Mattias Fagerlund
Ämne: JQGrid is not configuring in IIS [MVCjQueryControls:275993]

From: VelCodeplex

Hello all,

I have downloaded the JQGrid for MVC 3 application. Its working fine when i'm running from my local machine. But when i configured to iis its not working. Its not pointing out the exact action that what i called. Following lines are my code that i have written.

@Html.Grid(new GridControl()
.SetName("grid")
.SetPageSize(10)
.SetIsAutoSize(true)
.SetListUrl(Url.Action("Union", "Home")) // The URL is not working (404 Error)
.SetEditUrl(Url.Action("Union", "Home"))
.SetHeight("232")
.SetWidth("1000")
.UseColumns(MVCThreeJQGrid.Models.Columns.UnionColumns)
.UpdateDefaultPager(pager =>
pager
.ShowAdd(true)
.ShowDel(true, deleteUrl: Url.Action("Union", "Home"))
.ShowEdit(true)
.ShowView(true)
))

Oct 18, 2011 at 6:51 AM

Below output was generated from my code

<script language="javascript">$(document).ready(function() {
_grid_init("grid");
$("#grid").jqGrid({
url: "/JQGrid/Home.mvc/Union",
sortable: true,
editurl: "/JQGrid/Home.mvc/Union",
mtype: "get",
datatype: "json",
colNames: ["Union No","Union Name","Tax ID","Local No","Effective Date","Termination Date","Comments"],
colModel: [{ name: "UNION_ID", index: "UNION_ID", width: 50, align: "center", sortable: true, key: true, editable: true, hidden: false, edittype: 'text', editoptions: {dataEvents: [{ type: 'change', fn:function(e){doCascade(e);}}]}},
{ name: "UNION_NAME", index: "UNION_NAME", width: 50, align: "left", sortable: true, editable: true, hidden: false, edittype: 'text', editoptions: {dataEvents: [{ type: 'change', fn:function(e){doCascade(e);}}]}},
{ name: "TAX_ID", index: "TAX_ID", width: 50, align: "center", sortable: true, editable: true, hidden: false, edittype: 'text'},
{ name: "LOCAL_NO", index: "LOCAL_NO", width: 50, align: "left", sortable: true, editable: true, hidden: false, edittype: 'text'},
{ name: "EFF_DATE", index: "EFF_DATE", width: 50, align: "center", sortable: true, editable: true, hidden: true, edittype: 'text'},
{ name: "TERM_DATE", index: "TERM_DATE", width: 50, align: "center", sortable: true, editable: true, hidden: true, edittype: 'text'},
{ name: "COMMENTS", index: "COMMENTS", width: 50, align: "left", sortable: true, editable: true, hidden: false, edittype: 'text'}],
rowNum: 10,
prmNames: {id: "UNION_ID"},
gridComplete: function f(){updateButtonState($('#grid'));},
height: 232,
width: 1000,
rowList: [10, 20, 30, 50],
pager: $("#gridPager"),sortname: "UNION_ID",
autowidth: true,
onSelectRow: function(id){updateButtonState($('#grid'));
if ($("#Id").length == 0) {return;}$("#Id")[0].value = $("#grid").getRowData(id).UNION_ID;},caption: ""});
$('#grid').navGrid('#gridPager',{add: true, edit:true, del: true, search: true, view: true, refresh: true},{afterSubmit:handleMvcResponse}, {afterSubmit:handleMvcResponse}, {url:"/JQGrid/Home.mvc/Union",afterSubmit:handleMvcResponse}, {closeOnEscape: true,multipleSearch:true});
});
</script>

This below URL was generated and mentioned as 404(File not found).  from HTTP watcher

http://localhost/JQGrid/Home.mvc/Union?_search=false&nd=1318920581491&rows=10&page=1&sidx=UNION_ID&sord=asc

Oct 18, 2011 at 6:56 AM


Below is my controller. It loads the Index from View Index, and it does not hit the Union

public ActionResult Index()           //Index
        {
            List<UnionModel> model = new List<UnionModel>();
            string sUri = string.Format("{0}/GetUnionMain?order by union_id desc", context.BaseUri);
            var UnionInfo = context.Execute<Type_UnionMain>(new Uri(sUri, UriKind.Absolute)).ToList();
            foreach (var r in UnionInfo)
            {
                model.Add(new UnionModel { UNION_ID = r.UNION_ID, COMMENTS = r.COMMENTS, UNION_NAME = r.UNION_NAME, TAX_ID = r.TAX_ID, LOCAL_NO = r.LOCAL_NO, EFF_DATE = Convert.ToDateTime(r.EFF_DATE), TERM_DATE = Convert.ToDateTime(r.TERM_DATE) });
            }
            ViewData["Union"] = model;
            return View();
        }

public ActionResult Union(SearchModel searchModel)            //Union
        {
            List<UnionModel> model = new List<UnionModel>();
            string sUri = string.Format("{0}/GetUnionMain?order by union_id desc", context.BaseUri);
            var UnionInfo = context.Execute<Type_UnionMain>(new Uri(sUri, UriKind.Absolute)).ToList();
            foreach (var r in UnionInfo)
            {
                model.Add(new UnionModel { UNION_ID = r.UNION_ID, COMMENTS = r.COMMENTS, UNION_NAME = r.UNION_NAME, TAX_ID = r.TAX_ID, LOCAL_NO = r.LOCAL_NO, EFF_DATE = Convert.ToDateTime(r.EFF_DATE), TERM_DATE = Convert.ToDateTime(r.TERM_DATE) });
            }
            GridData gridData = model.AsQueryable().ToGridData(searchModel, Columns.UnionColumns);
            return Json(gridData, JsonRequestBehavior.AllowGet);
        }

Developer
Oct 18, 2011 at 7:13 AM
Ok
* What's the URL of your page containing the grid? If it is NOT "/JQGrid/Home.mvc/" then you need to figure out why the wrong url is being created, and what to do about it;
* Try to figure out what the URL should be and from there determine what's going wrong.
* Are you using areas?
* Are you using a base url (everything should appear in the /etc/tools/ path, for instance)? Is that area appearing in one url (the page url) but not the other (the grid list url)? Or the other way around?
* If it IS the correct URL you need to figure out if the problem is that the request is incorrectly routed or if it's a case of the parameters being wrong for the method call.
cheers,
mattias

Från: VelCodePlex [notifications@codeplex.com]
Skickat: den 18 oktober 2011 08:51
Till: Mattias Fagerlund
Ämne: Re: JQGrid is not configuring in IIS [MVCjQueryControls:275993]

From: VelCodePlex

Below output was generated from my code

<script language="javascript">$(document).ready(function() {
_grid_init("grid");
$("#grid").jqGrid({
url: "/JQGrid/Home.mvc/Union",
sortable: true,
editurl: "/JQGrid/Home.mvc/Union",
mtype: "get",
datatype: "json",
colNames: ["Union No","Union Name","Tax ID","Local No","Effective Date","Termination Date","Comments"],
colModel: [{ name: "UNION_ID", index: "UNION_ID", width: 50, align: "center", sortable: true, key: true, editable: true, hidden: false, edittype: 'text', editoptions: {dataEvents: [{ type: 'change', fn:function(e){doCascade(e);}}]}},
{ name: "UNION_NAME", index: "UNION_NAME", width: 50, align: "left", sortable: true, editable: true, hidden: false, edittype: 'text', editoptions: {dataEvents: [{ type: 'change', fn:function(e){doCascade(e);}}]}},
{ name: "TAX_ID", index: "TAX_ID", width: 50, align: "center", sortable: true, editable: true, hidden: false, edittype: 'text'},
{ name: "LOCAL_NO", index: "LOCAL_NO", width: 50, align: "left", sortable: true, editable: true, hidden: false, edittype: 'text'},
{ name: "EFF_DATE", index: "EFF_DATE", width: 50, align: "center", sortable: true, editable: true, hidden: true, edittype: 'text'},
{ name: "TERM_DATE", index: "TERM_DATE", width: 50, align: "center", sortable: true, editable: true, hidden: true, edittype: 'text'},
{ name: "COMMENTS", index: "COMMENTS", width: 50, align: "left", sortable: true, editable: true, hidden: false, edittype: 'text'}],
rowNum: 10,
prmNames: {id: "UNION_ID"},
gridComplete: function f(){updateButtonState($('#grid'));},
height: 232,
width: 1000,
rowList: [10, 20, 30, 50],
pager: $("#gridPager"),sortname: "UNION_ID",
autowidth: true,
onSelectRow: function(id){updateButtonState($('#grid'));
if ($("#Id").length == 0) {return;}$("#Id")[0].value = $("#grid").getRowData(id).UNION_ID;},caption: ""});
$('#grid').navGrid('#gridPager',{add: true, edit:true, del: true, search: true, view: true, refresh: true},{afterSubmit:handleMvcResponse}, {afterSubmit:handleMvcResponse}, {url:"/JQGrid/Home.mvc/Union",afterSubmit:handleMvcResponse}, {closeOnEscape: true,multipleSearch:true});
});
</script>

This below URL was generated and mentioned as 404(File not found). from HTTP watcher

http://localhost/JQGrid/Home.mvc/Union?_search=false&nd=1318920581491&rows=10&page=1&sidx=UNION_ID&sord=asc

Coordinator
Oct 18, 2011 at 7:13 AM

Are you sure you set up the Action link correctly?

By your reply I understand the view's name is Index, if so maybe the correct syntax should have been: Url.Action("Union", "Index")

If that doesnt work, could you upload a sample project with the bug so we could better understand the problem and what causing it?

Oct 18, 2011 at 9:28 AM

Please download the source from the below link, and run the application from your local server, it will work. Then you configure the same source in IIS it won't work. Please let me know if any other possibility. Since it does not call the action in the controller.

http://mvcjquerycontrols.codeplex.com/SourceControl/list/changesets

Oct 18, 2011 at 9:35 AM

Please download the source from the below link, and run the application from your local server, it will work. Then you configure the same source in IIS it won't work. Please let me know if any other possibility. Since it does not call the action in the controller.

http://mvcjquerycontrols.codeplex.com/SourceControl/list/changesets

Aug 30, 2012 at 6:53 AM
Edited Aug 30, 2012 at 6:53 AM

I also meet this problem in my local machine IIS

It's seems the following code in MVCControlsScriptManager makes the Script and CSS files point to a wrong location.

"RegisterScriptsAndStyles("../../Content/MVCControls/", "../../Scripts/MVCControls/");"

 

After:

This is my change.

RegisterScriptsAndStyles(System.Web.VirtualPathUtility.ToAbsolute("~/Content/MVCControls/"), System.Web.VirtualPathUtility.ToAbsolute("~/Scripts/MVCControls/"));

 

It works in my machine now.