Jquery 厚盒与 Asp.net mvc 中的 Url.Action 链接一起使用

发布于 2024-09-11 04:27:46 字数 1487 浏览 8 评论 0原文

我想实现一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

娇柔作态 2024-09-18 04:27:46

我让 Html.ActionLink 帮助程序渲染出包含代码的链接,如下所示:

    <%=Html.ActionLink(Resources.Localize.Routes_WidgetsCreate, "Create", "Widget",  new { modal = true },
                                      new
                                        {
                                            rel = "shadowbox;height=600;width=700",
                                            title = Resources.Localize.Routes_WidgetsCreate
                                        })%>

说明:
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:

    <%=Html.ActionLink(Resources.Localize.Routes_WidgetsCreate, "Create", "Widget",  new { modal = true },
                                      new
                                        {
                                            rel = "shadowbox;height=600;width=700",
                                            title = Resources.Localize.Routes_WidgetsCreate
                                        })%>

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

淡看悲欢离合 2024-09-18 04:27:46

我不认为这与thickbox有关,但是你能确认你的两个代码片段(下面)实际上渲染了一个url吗?

<%=Url.Action("ShowPhoto", "Item", new { id = pic.pictureID })  %>

<%= Url.Action("ShowThumbnail", "Item", new { id = pic.pictureID }) %>

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?

<%=Url.Action("ShowPhoto", "Item", new { id = pic.pictureID })  %>

and

<%= Url.Action("ShowThumbnail", "Item", new { id = pic.pictureID }) %>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文