2015-11-06 39 views
0

我有这样的控制器:为什么我的行动结果给我一个404?

public class ActivityController : Controller 
    { 
     // GET: Activity 
     [HttpGet] 
     public ActionResult ProfessionalActivityForm() 
     { 
      return View(new Activity()); 
     } 
     public ActionResult TradeShow() 
     { 
      return PartialView("_AddTradeShow"); 
     } 
     public ActionResult InsertTradeShow(TradeShow TradeShow) 
     { 
      TradeShow.Insert(TradeShow); 
      return Content("Trade Show submitted successfully"); 
     } 
     public ActionResult Conference() 
     { 
      return PartialView("_AddConference"); 
     } 
     public ActionResult InsertConference(Conference Conference) 
     { 
      Conference.Insert(Conference); 
      return Content("Conference submitted successfully"); 
     } 
    } 

,当我做了一个/Activity/ConferenceGET让我的部分观点还给我就好了。然后,如果我切换此控制器中的代码,以使会议出现在TradeShow之前,那么我会得到相反的结果 - 会议404和TradeShow的工作分部视图。

这是为什么?好像我失去了一些东西在这里根本...

这里是jQuery的我使用AJAX:

$('#ConferenceButton').on('click', function() { 
     $.ajax({ 
      type: "GET", 
      url: '/Activity/Conference', 
      success: function (data, textStatus, jqXHR) { 
       $('#partialViewContainer').html(data); 
       $('.focusMe').focus(); 
       //var top = $('.focusMe').offset().top; 
       //$("html, body").animate({ scrollTop: top }, 700); 
      } 
     }); 
    }); 
    $('#TradeShowButton').on('click', function() { 
     $.ajax({ 
      type: "GET", 
      url: '/Activity/TradeShow', 
      success: function (data, textStatus, jqXHR) { 
       $('#partialViewContainer').html(data); 
       $('.focusMe').focus(); 
       //var top = $('.focusMe').offset().top; 
       //$("html, body").animate({ scrollTop: top }, 700); 
      } 
     }); 
    }); 
+0

尝试在你'$ .ajax'能指定'的dataType = “HTML”'是默认智能猜测可以gess什么来自控制器。 –

回答

1

您可以尝试在$.ajax({更换url

url: '@Url.Action("Conference", "Activity")', 

url: '@Url.Action("TradeShow", "Activity")', 

此外,如果您的ConferenceButtonTradeShowButton个使用ActionLinks在查看这样的:

@Html.ActionLink("Conference Button", "Conference", "Activity", null, new { id = "ConferenceButton" }) 

,那么你可以在url使用此代码:

url: this.href, 
相关问题