Hi, I'm using V.S. 2008, C# for this Web page at http://www.labctsi.org/Members/SearchMembers.aspx/Index. User would select from the Select controls and click the add button and then click the Search button and I get message of
The IControllerFactory 'CtsiMembershipApplication.MyControllerFactory' did not return a controller for a controller named 'SearchMembers'.
The url for this page is "http://www.labctsi.org/SearchMembers.aspx/Search/" which is incorrect becuase it should have been http://www.labctsi.org/Members/SearchMembers.aspx/Search/. I put in this url and then I get a different error for
HTTP 404.
For the 1st error message is very confusing for me. For this ASP.NET MVC project, I did copy serveral classes code from another project named, CtsiMembershipApplication" but I don't have MyControllerFactory in my prject. Actually, I just don't have any
Controllerfactory class in my project becuase I did a search for this and found none. I also did a serach for CtsiMembershipApplication and found nothing either.
How can I correct this so
1. when my form is submitted it will go to the right Action(Search) in my (one and only one) controller with correct url?
2. How can I reset the researchInterests variable to null from the Search Action after it receives it? (This variable is declared and construted in my Search view)
<script type="text/javascript">
$(document).ready(function() {
var selectBox;
var selectedText;
var researchInterestFullName;
var addToHiddenField;
var selectedResearchInterestCount;
selectedResearchInterestCount = 0;
var professionalOrganizationCount;
professionalOrganizationCount = 0;
using System.Web.Mvc;
using CtsiSearchMembership.Models;
namespace CtsiSearchMembership.Controllers
{
public class SearchMembersController : Controller
{
public IResearchInterestRepository ResearchInterestRepository { get; set; }
public SearchMembersController()
{
var researchInterestRepository = new ResearchInterestRepository();
ResearchInterestRepository = researchInterestRepository;
}
//
// GET: /SearchMembers/
public ActionResult Index()
{
ViewData["Level1ResearchInterests"] = ResearchInterestRepository.FindByParentResearchInterestId(0);
return View("Search");
}
public JsonResult GetChildResearchInterests(long id)
{
var result = new JsonResult { Data = ResearchInterestRepository.FindByParentResearchInterestId(id) };
return result;
}
I search through my solution and nothing with ControllerFactory is found. Below is my Global.asax.cs. Thank you.
namespace CtsiSearchMembership
{
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
// visit http://go.microsoft.com/?LinkId=9394801
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}.aspx/{action}/{id}", // URL with parameters
new { controller = "SearchMembers", action = "Index", id = "" } // Parameter defaults
);
Hi, I modified my code to use the HTML helper. I publish the code and now the cascading Select controls do no populate . When i select any itme in the 1st Select control, I get these error from the FireBug
<html> <head> <title>The IControllerFactory 'CtsiMembershipApplication.MyControllerFactory' did not return a controller for a controller named 'SearchMembers'.</title> <style>
Please, when can I find the code that's causing this message and error. How can I correct this? Thank you.
I already searched for MyControllerFactory and Factory through the entire solution several times in different ways. I did it again since you mentioned it and still nothing is found. That is so confusing why my application is mentioning this. Thanks.
Taichung
Member
28 Points
75 Posts
When form action url is submitted, the url shows incorrect
Jun 10, 2010 10:50 PM|LINK
Hi, I'm using V.S. 2008, C# for this Web page at http://www.labctsi.org/Members/SearchMembers.aspx/Index. User would select from the Select controls and click the add button and then click the Search button and I get message of
The IControllerFactory 'CtsiMembershipApplication.MyControllerFactory' did not return a controller for a controller named 'SearchMembers'.
The url for this page is "http://www.labctsi.org/SearchMembers.aspx/Search/" which is incorrect becuase it should have been http://www.labctsi.org/Members/SearchMembers.aspx/Search/. I put in this url and then I get a different error for HTTP 404.
For the 1st error message is very confusing for me. For this ASP.NET MVC project, I did copy serveral classes code from another project named, CtsiMembershipApplication" but I don't have MyControllerFactory in my prject. Actually, I just don't have any Controllerfactory class in my project becuase I did a search for this and found none. I also did a serach for CtsiMembershipApplication and found nothing either.
How can I correct this so
1. when my form is submitted it will go to the right Action(Search) in my (one and only one) controller with correct url?
2. How can I reset the researchInterests variable to null from the Search Action after it receives it? (This variable is declared and construted in my Search view)
Thank you.
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="CtsiSearchMembership.Models"%>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript">
$(document).ready(function() {
var selectBox;
var selectedText;
var researchInterestFullName;
var addToHiddenField;
var selectedResearchInterestCount;
selectedResearchInterestCount = 0;
var professionalOrganizationCount;
professionalOrganizationCount = 0;
var interestIds = new Array();
$('#level2ResearchInterests').hide();
$('#level3ResearchInterests').hide();
$('#level4ResearchInterests').hide();
$("#level1ResearchInterests").change(function() {
$.getJSON("/Membership.aspx/GetChildResearchInterests/" + $(this).val(), function(json) {
var options = '';
for (var i = 0; i < json.length; i++) {
options += '<option value="' + json[i].Id + '">' + json[i].Name + '</option>';
}
$("#level2ResearchInterests").html(options);
$("#level3ResearchInterests").html('');
$("#level4ResearchInterests").html('');
if (json.length > 0) {
$('#level1ResearchInterests').animate({ width: 170 }, 'fast', function() {
$('#level2ResearchInterests').css('width', '340px');
$('#level2ResearchInterests').fadeIn('fast');
});
}
else {
$('#level2ResearchInterests').fadeOut('fast');
}
$('#level3ResearchInterests').fadeOut('fast');
$('#level4ResearchInterests').fadeOut('fast');
})
})
$("#level2ResearchInterests").change(function() {
$.getJSON("/Membership.aspx/GetChildResearchInterests/" + $(this).val(), function(json) {
var options = '';
for (var i = 0; i < json.length; i++) {
options += '<option value="' + json[i].Id + '">' + json[i].Name + '</option>';
}
$("#level3ResearchInterests").html(options);
$("#level4ResearchInterests").html('');
$('#level2ResearchInterests').fadeIn('fast');
if (json.length > 0) {
$('#level2ResearchInterests').animate({ width: 170 }, 'fast', function() {
$('#level3ResearchInterests').css('width', '340px');
$('#level3ResearchInterests').fadeIn('fast');
});
}
else {
$('#level3ResearchInterests').fadeOut('fast');
}
$('#level4ResearchInterests').fadeOut('fast');
})
})
$("#level3ResearchInterests").change(function() {
$.getJSON("/Membership.aspx/GetChildResearchInterests/" + $(this).val(), function(json) {
var options = '';
for (var i = 0; i < json.length; i++) {
options += '<option value="' + json[i].Id + '">' + json[i].Name + '</option>';
}
$("#level4ResearchInterests").html(options);
$('#level2ResearchInterests').fadeIn('fast');
$('#level3ResearchInterests').fadeIn('fast');
if (json.length > 0) {
$('#level3ResearchInterests').animate({ width: 170 }, 'fast', function() {
$('#level4ResearchInterests').fadeIn('fast');
});
}
else {
$('#level4ResearchInterests').fadeOut('fast');
}
})
})
//Finally reset all the research interests
var resetResearchInterestSelection = function() {
$("#level2ResearchInterests").hide();
$("#level3ResearchInterests").hide();
$("#level4ResearchInterests").hide();
$("#level2ResearchInterests").html('');
$("#level3ResearchInterests").html('');
$("#level4ResearchInterests").html('');
$('#level1ResearchInterests').attr('selectedIndex', '-1');
$('#level1ResearchInterests').animate({ width: 340 }, 'fast');
};
$("#addResearchInterest").click(function() {
if ($('#level1ResearchInterests').val() == null) return; //Nothing has been selected, so return
//Clear out the table which shows the selected research interests if necessary.
if (selectedResearchInterestCount == 0) { $('table#selectedResearchInterests tbody tr').remove(); };
var selectedId;
researchInterestFullName = '';
addToHiddenField = 1;
//Start from level 4 research interests, we basically only store the id of the selected Id of the lowest level Research Interest, as its parents can be inferred.
if ($('#level4ResearchInterests').val() != null) {
if (addToHiddenField == 1) $("#researchInterests").val($("#researchInterests").val() + $('#level4ResearchInterests').val() + ',');
addToHiddenField = 0;
selectBox = document.getElementById("level4ResearchInterests");
selectedText = selectBox.options[selectBox.selectedIndex].text;
researchInterestFullName = ">" + selectedText;
selectedId = $('#level4ResearchInterests').val();
};
if ($('#level3ResearchInterests').val() != null) {
if (addToHiddenField == 1) $("#researchInterests").val($("#researchInterests").val() + $('#level3ResearchInterests').val() + ',');
addToHiddenField = 0;
selectBox = document.getElementById("level3ResearchInterests");
selectedText = selectBox.options[selectBox.selectedIndex].text;
researchInterestFullName = ">" + selectedText + researchInterestFullName;
};
if ($('#level2ResearchInterests').val() != null) {
if (addToHiddenField == 1) $("#researchInterests").val($("#researchInterests").val() + $('#level2ResearchInterests').val() + ',');
addToHiddenField = 0;
selectBox = document.getElementById("level2ResearchInterests");
selectedText = selectBox.options[selectBox.selectedIndex].text;
researchInterestFullName = ">" + selectedText + researchInterestFullName;
};
if ($('#level1ResearchInterests').val() != null) {
if (addToHiddenField == 1) $("#researchInterests").val($("#researchInterests").val() + $('#level1ResearchInterests').val() + ',');
addToHiddenField = 0;
selectBox = document.getElementById("level1ResearchInterests");
selectedText = selectBox.options[selectBox.selectedIndex].text;
researchInterestFullName = selectedText + researchInterestFullName;
selectedResearchInterestCount++;
$('<tr><td>' + selectedResearchInterestCount + '</td><td>' + researchInterestFullName + '</td></tr>').appendTo('#selectedResearchInterests tbody').animate({ backgroundColor: 'yellow' }, 500).animate({ backgroundColor: 'white' }, 500, resetResearchInterestSelection);
//Apply the classes in order to get striping
$('#selectedResearchInterests tbody tr:odd').removeClass('even').addClass('odd');
$('#selectedResearchInterests tbody tr:even').removeClass('odd').addClass('even');
};
alert("Selected ids are : " + $("#researchInterests").val());
return false;
})
$('#level1ResearchInterests').css('width', '340px');
})
</script>
<form action="/SearchMembers.aspx/Search/" method="post">
<input type="hidden" name="ResearchInterests" id="researchInterests" value=""/>
<fieldset>
<h1>Search CTSI Members</h1>
<br />
<label>Areas of Research Interest</label>
<select id="level1ResearchInterests" name="Level1ResearchInterests" size="5" tabindex="1">
<% foreach (ResearchInterest researchInterest in ViewData["Level1ResearchInterests"] as IList<ResearchInterest>) { %>
<option value="<%=researchInterest.Id%>"><%=researchInterest.Name%></option>
<% } %>
</select>
<select id="level2ResearchInterests" name="Level2ResearchInterests" size="5">
</select>
<select id="level3ResearchInterests" name="Level3ResearchInterests" size="5">
</select>
<select id="level4ResearchInterests" name="Level4ResearchInterests" size="5">
</select><br /><br />
<div>
<input type="button" id="addResearchInterest" value="Add Research Interest to my search criteria(s)" />
</div>
<br />
<table id='selectedResearchInterests'>
<thead>
<tr>
<th></th>
<th>My selected Research Interest</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>No Research Interests selected yet.</td>
</tr>
</tbody>
</table>
</fieldset>
<div>
<input type="submit" id="searchMembers" value="Search" tabindex="2" />
</div>
</form>
</asp:Content>
using System;
using System.Web.Mvc;
using CtsiSearchMembership.Models;
namespace CtsiSearchMembership.Controllers
{
public class SearchMembersController : Controller
{
public IResearchInterestRepository ResearchInterestRepository { get; set; }
public SearchMembersController()
{
var researchInterestRepository = new ResearchInterestRepository();
ResearchInterestRepository = researchInterestRepository;
}
//
// GET: /SearchMembers/
public ActionResult Index()
{
ViewData["Level1ResearchInterests"] = ResearchInterestRepository.FindByParentResearchInterestId(0);
return View("Search");
}
public JsonResult GetChildResearchInterests(long id)
{
var result = new JsonResult { Data = ResearchInterestRepository.FindByParentResearchInterestId(id) };
return result;
}
[AcceptVerbs(HttpVerbs.Post)]
public ViewResult Search(string researchInterestsString)
{
var interestIds = researchInterestsString;
//var interestIds = Request.Form["researchInterests"].ToString().Trim();
if (interestIds[interestIds.Length - 1] == ',')
interestIds = interestIds.Remove(interestIds.Length - 1);
ViewData["Members"] = ResearchInterestRepository.FindMembersByInterestIds(interestIds);
researchInterestsString = string.Empty;
ViewData["Level1ResearchInterests"] = ResearchInterestRepository.FindByParentResearchInterestId(0);
return View("List");
}
}
}
ignatandrei
All-Star
134973 Points
21638 Posts
Moderator
MVP
Re: When form action url is submitted, the url shows incorrect
Jun 11, 2010 04:27 AM|LINK
What do you have in global.asax like
?
Taichung
Member
28 Points
75 Posts
Re: When form action url is submitted, the url shows incorrect
Jun 11, 2010 05:13 PM|LINK
I search through my solution and nothing with ControllerFactory is found. Below is my Global.asax.cs. Thank you.
namespace CtsiSearchMembership
{
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
// visit http://go.microsoft.com/?LinkId=9394801
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}.aspx/{action}/{id}", // URL with parameters
new { controller = "SearchMembers", action = "Index", id = "" } // Parameter defaults
);
}
protected void Application_Start()
{
RegisterRoutes(RouteTable.Routes);
}
}
}
Taichung
Member
28 Points
75 Posts
Re: When form action url is submitted, the url shows incorrect
Jun 12, 2010 12:33 AM|LINK
Hi, I modified my code to use the HTML helper. I publish the code and now the cascading Select controls do no populate . When i select any itme in the 1st Select control, I get these error from the FireBug
ignatandrei
All-Star
134973 Points
21638 Posts
Moderator
MVP
Re: When form action url is submitted, the url shows incorrect
Jun 12, 2010 05:59 AM|LINK
Please search in your solution for
MyControllerFactory
I doubt that such a name exists in the MVC framework...
Taichung
Member
28 Points
75 Posts
Re: When form action url is submitted, the url shows incorrect
Jun 14, 2010 05:50 PM|LINK
I already searched for MyControllerFactory and Factory through the entire solution several times in different ways. I did it again since you mentioned it and still nothing is found. That is so confusing why my application is mentioning this. Thanks.
ignatandrei
All-Star
134973 Points
21638 Posts
Moderator
MVP
Re: When form action url is submitted, the url shows incorrect
Jun 15, 2010 04:14 AM|LINK
If you do not find either some unusual references, Sorry, I can not help ....