Nutch与Solr(Nutch versus Solr)
目前收集我应该使用Nutch与Solr的信息(域名 - 垂直网页搜索)。
你能建议我吗?
Currently collecting information where I should use Nutch with Solr (domain - vertical web search).
Could you suggest me?
原文:https://stackoverflow.com/questions/2818112
最满意答案
当然你可以这样做:
<% Html.Partial("_ListTodos", userTodos); %>
将
userTodos
作为参数传递给部分助手。你得到的错误是因为你返回的索引页面/视图与
return View(todos);
在Index
操作方法中。 Index页面需要一个LoginModel
对象,而不是IEnumerable
的待办事项对象。<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<todo_moble_oauth.Models.LoginModel>" %>
要解决这个问题,你需要改变你传递
todos
的方式。 由于您的Index
页面接收到LoginModel
,您可以像这样将Todos
属性添加到此类中:[Required] [Display(Name = "User name")] public string UserName { get; set; } [Required] [DataType(DataType.Password)] [Display(Name = "Password")] public string Password { get; set; } [Display(Name = "Remember me?")] public bool RememberMe { get; set; } public IEnumerable<todo_moble_oauth.Models.todo> Todos { get; set; }
然后修改您的索引操作方法:
[AllowAnonymous] public ActionResult Index() { // if user is logged in, show todo list if (Request.IsAuthenticated) { //var currentUser = Membership.GetUser().ProviderUserKey; todosDataContext objLinq = new todosDataContext(); var todos = objLinq.todos.Select(x => x); LoginModel model = new LoginModel(); model.Todos = todos; return View(model); } return View(); }
在该视图中,请执行以下操作:
<% Html.Partial("_ListTodos", Model.Todos); %>
Sure you can do that:
<% Html.Partial("_ListTodos", userTodos); %>
Pass the
userTodos
as a parameter to the Partial helper.The error you're getting is because you're returning a list of todos to the Index page/view with
return View(todos);
inside theIndex
action method. The Index page needs aLoginModel
object instead of anIEnumerable
of todo objects.<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<todo_moble_oauth.Models.LoginModel>" %>
To solve this, you need to change the way you're passing the
todos
though. Since yourIndex
page receives aLoginModel
, you can add aTodos
property to this class like this:[Required] [Display(Name = "User name")] public string UserName { get; set; } [Required] [DataType(DataType.Password)] [Display(Name = "Password")] public string Password { get; set; } [Display(Name = "Remember me?")] public bool RememberMe { get; set; } public IEnumerable<todo_moble_oauth.Models.todo> Todos { get; set; }
and then, modify your Index action method:
[AllowAnonymous] public ActionResult Index() { // if user is logged in, show todo list if (Request.IsAuthenticated) { //var currentUser = Membership.GetUser().ProviderUserKey; todosDataContext objLinq = new todosDataContext(); var todos = objLinq.todos.Select(x => x); LoginModel model = new LoginModel(); model.Todos = todos; return View(model); } return View(); }
In the view, do this:
<% Html.Partial("_ListTodos", Model.Todos); %>
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
当然你可以这样做: <% Html.Partial("_ListTodos", userTodos); %> 将userTodos作为参数传递给部分助手。 你得到的错误是因为你返回的索引页面/视图与return View(todos); 在Index操作方法中。 Index页面需要一个LoginModel对象,而不是IEnumerable的待办事项对象。 <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inher ...
-
如何在ASP.NET MVC局部视图中使用匿名列表作为模型?(How to use anonymous list as model in an ASP.NET MVC partial view?)[2021-09-20]
不要这样做。 不要将匿名对象传递给您的视图。 它们的属性是内部的,在其他程序集中不可见。 ASP.NET运行时将视图动态编译为单独的动态程序集。 因此,定义视图模型并强制输入您的视图。 喜欢这个: public class PersonViewModel { public string FirstName { get; set; } public string LastName { get; set; } } 接着: var model = new PersonViewModel { ... -
也许它因为你的js文件应该是下一个格式 1 jquery 2 jquery.unobstrusive 3 jquery.unobstrusive-ajax Thanks for the all the help. I found another way to show the Partial View. I just add a jquery function and call it on the onClick event. Below is the code if anybody needs. jQu ...
-
我认为你必须为你的登录页面创建另一个模型: class LogInModel { public string UserName { get; set; } public string Pass { get; set; } public bool StayLoggedIn { get; set; } } 并基于此模型创建视图,并在控制器中只检索此模式。 在登录页面中使用用户模型不是一个好主意。 I think you must create another model for yo ...
-
如果要调用操作,即使操作将返回局部视图,您也应该使用。 @Html.Action("_Deleted", "Daftar") // Assume _Deleted is inside DaftarController 这将调用操作然后返回视图,并且在_Deleted操作中,您需要使用PartialView方法返回它,否则布局将作为结果包含在内。 public ActionResult _Deleted() { List
li = ws.GetDeleteds().To ... -
你可以为你的目的使System.Linq工作,但我强烈建议反对它。 您最终将使用ElementAt多次迭代您的集合。 随着您的收藏增长,性能将变得非常糟糕。 使用foreach循环并自己跟踪索引会好得多(请原谅razor语法,如果有点关闭): @{ var counter = 0; } @foreach(var kvp in @Model.content) { @if(counter > 0){
- @kvp.Value ...
-
您的模型有公共字段但不包含公共属性,这些不一样。 改成: public class CustomerModel { [Required] public Guid Id {get; set;} [Required] public string Name {get; set;} [Required] public string Description {get; set;} } 默认的MVC模型绑定器将使用属性,而不是字段。 更多关于这里 - http:/ ...
-
ASP.Net MVC4会员资格(ASP.Net MVC4 Membership)[2022-05-28]
默认的ASP.NET MVC 4“Internet应用程序”项目模板附带一些默认的成员资格功能。 如果您搜索并更新下面的行,则会在您的数据库中创建成员资格表(如果它们尚不存在): WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true); 更多信息: http://aaron-hoffman.blogspot.com/2 ... -
ASP.Net MVC4将“创建视图”绑定到包含List的模型(ASP.Net MVC4 bind a “create view” to a model that contains List)[2022-12-05]
我最近发现自己需要完成相同的任务,并且像你一样,不想添加一堆javascript。 我正在使用MVC4,并且我可以说,似乎没有一种开箱即用的方法将模型的可枚举属性绑定到视图。 :( 但是,正如您在问题中所演示的那样, 可以从视图中的模型中检索可枚举属性。 诀窍是将更新恢复到控制器。 离开您的示例模型,您的视图可能看起来像这样(您不需要部分): @model MVCComplexObjects.Models.ComplexObject@Html.ActionLink("Create New", " ...