Jquery 厚盒与 Asp.net mvc 中的 Url.Action 链接一起使用
我想实现一个 Jquery 厚盒来显示从 ASP.Net MVC 中的数据库生成的图像。我的链接大致如下所示:
<a href="<%=Url.Action("ShowPhoto", "Item", new { id = pic.pictureID }) %>" class="thickbox"><img src="<%= Url.Action( "ShowThumbnail", "Item", new { id = pic.pictureID } ) %>" alt="" width="100px" /></a>
但是,我遇到了由 Url.Action 链接导致的错误弹出。
有人请帮助我!
编辑:抱歉,我忘记输入错误。
在 Visual Studio 中:
用户代码未处理 NullReferenceException。你调用的对象是空的。 (这在 UnitofWork.CurrentUnitOfWork.Dispose() 中突出显示;)
在我的错误日志中:
System.Web.HttpException(0x80004005): 潜在危险的 Request.Path 从客户端检测到值 (&)。在 System.Web.HttpRequest.ValidateInputIfRequiredByConfig() 在 System.Web.HttpApplication.ValidateRequestExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 在 System.Web.HttpApplication.ExecuteStep(IExecutionStep 步骤,布尔值&同步完成)
System.Web.HttpException(0x80004005): 文件不存在。在 System.Web.StaticFileHandler.GetFileInfo(字符串 virtualPathWithPathInfo,字符串 物理路径,HttpResponse 响应)
在 System.Web.StaticFileHandler.ProcessRequestInternal(HttpContext 上下文,字符串覆盖VirtualPath)
在 System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext 上下文,AsyncCallback 回调, 对象状态)在 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 在 System.Web.HttpApplication.ExecuteStep(IExecutionStep 步骤,布尔值&同步完成)
I want to implement a Jquery thickbox to show an image that is generated from my database in ASP.Net MVC. My link looks roughly like this:
<a href="<%=Url.Action("ShowPhoto", "Item", new { id = pic.pictureID }) %>" class="thickbox"><img src="<%= Url.Action( "ShowThumbnail", "Item", new { id = pic.pictureID } ) %>" alt="" width="100px" /></a>
However, I'm having errors popping out caused by the Url.Action link.
Someone please help me!!
EDIT: Sorry, I forgot to put the error in.
In the Visual Studio:
NullReferenceException was unhandled by user code. Object reference not set to an instance of an object. (This is highlighted in UnitofWork.CurrentUnitOfWork.Dispose();)
In my error log:
System.Web.HttpException (0x80004005):
A potentially dangerous Request.Path
value was detected from the client
(&). at
System.Web.HttpRequest.ValidateInputIfRequiredByConfig()
at
System.Web.HttpApplication.ValidateRequestExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at
System.Web.HttpApplication.ExecuteStep(IExecutionStep
step, Boolean& completedSynchronously)System.Web.HttpException (0x80004005):
File does not exist. at
System.Web.StaticFileHandler.GetFileInfo(String
virtualPathWithPathInfo, String
physicalPath, HttpResponse response)
at
System.Web.StaticFileHandler.ProcessRequestInternal(HttpContext
context, String overrideVirtualPath)
at
System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext
context, AsyncCallback callback,
Object state) at
System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at
System.Web.HttpApplication.ExecuteStep(IExecutionStep
step, Boolean& completedSynchronously)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我让 Html.ActionLink 帮助程序渲染出包含代码的链接,如下所示:
说明:
Resources.Localize.Routes_WidgetsCreate 是对 Resources 类的引用,用于获取本地化字符串,
“创建”是控制器操作,
“Widget”是控制器,
“new { model = true }” 是 QueryString 参数,
“new { rel ... }”这些是标签属性。
这是 Shadowbox 链接的示例,该链接打开模态窗口,其中包含 ~/Widget/Create 返回的内容。
华泰
I let the Html.ActionLink helper render out the links that include code for me, like this:
Explanation:
Resources.Localize.Routes_WidgetsCreate is a reference to Resources class to get localized string,
"Create" is the controller action,
"Widget" is the controller,
"new { model = true }" is QueryString parameter,
"new { rel ... } " these are the tag attributes.
This is an example of a Shadowbox link that opens modal window with the contents that ~/Widget/Create returns.
HTH
我不认为这与thickbox有关,但是你能确认你的两个代码片段(下面)实际上渲染了一个url吗?
和
I don't think that this is to do with thickbox, but can you confirm that your two snippets of code (below) actually render a url?
and