Url.Action 如何工作 Asp.net MVC?
这与我问过的另一个问题有些相关,但我想为什么不单独问它。
如果我要在视图中放置类似以下内容,
<td><img src='<%= Url.Action( "DisplayImage" , "User" , new { id = item.id} ) %>' alt="" /></td>
它应该显示它吗?
<td>
<img src='/User.mvc/DisplayImage?id=U00915441' alt="" />
</td>
或者 src 属性的值实际上会被 UserController GetImage 操作的结果替换吗?
This is somewhat related to another question I've asked but I figure why not ask it seperately.
If I were to place something like the following in a view
<td><img src='<%= Url.Action( "DisplayImage" , "User" , new { id = item.id} ) %>' alt="" /></td>
Is it supposed to display this?
<td>
<img src='/User.mvc/DisplayImage?id=U00915441' alt="" />
</td>
Or would the value of the src-attribute actually be replaced with the results of the UserController GetImage Action?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它将构造操作的路径,返回一个 url,而不是执行操作的结果。
结果将是:
示例代码。假设您的用户模型将图像存储在字节数组中。如果您使用的是 LINQ 并且该属性是二进制,然后使用 ToArray() 方法将其转换为字节数组。请注意需要用户登录并使用 GET 请求的属性。
}
It will construct the path to the action, returning a url, not the results of executing the action.
The results will be:
Example code. assumes your user model has the image stored in a byte array. If you are using LINQ and the property is a Binary, then use the ToArray() method to convert it to a byte array. Note the attributes which will require that the user be logged in and using a GET request.
}