简体   繁体   English

Site.Master页上的ASP.NET MVC 2数据收集

[英]ASP.NET MVC 2 Data Collection on Site.Master Page

I have a site.master page in which I need to collect a newsletter signup, so I would prefer if I can provide feedback immediately to the user as they signup, and not disrupt any other page activities. 我有一个site.master页面,我需要在其中收集新闻简报注册,因此,如果我可以在用户注册时立即向用户提供反馈,并且不中断任何其他页面活动,则希望这样做。 It is a simple textbox and button. 这是一个简单的文本框和按钮。

The data then gets written to a remote WCF web service, so could I use an AJAX call, although that would be cross domain, which might be an issue. 然后将数据写入远程WCF Web服务,因此我可以使用AJAX调用,尽管那将是跨域的,这可能是一个问题。 The service returns a message of success or why failed. 该服务返回成功或失败原因的消息。

So, my questions are, what would be the best approach for this implementation, and can I use the service? 因此,我的问题是,什么是实现此方案的最佳方法,我可以使用该服务吗?

Thanks! 谢谢! Brad 布拉德

In order to avoid the cross-domain problem, I would use the "double hop" solution. 为了避免跨域问题,我将使用“双跳”解决方案。 First, add a reference to the WCF service in your project. 首先,在您的项目中添加对WCF服务的引用。 Then create a method in your Controller that returns a JsonResult , and inside that method you can call the WCF service and return the result as JSON. 然后在Controller中创建一个返回JsonResult方法,然后在该方法内调用WCF服务并将结果作为JSON返回。

Then in the client app you can use a standard .ajax() method to do the sign-up. 然后,在客户端应用程序中,您可以使用标准的.ajax()方法进行注册。 It's a little convoluted with the number of hops, but it lets you control each step of the process and avoids the cross-domain problem. 它与跃点数有些混淆,但是它使您可以控制过程的每个步骤,并避免了跨域问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 访问部分视图中的数据库信息,即asp.net mvc中Site.Master中包含的.ascx - access database info in a partial view, .ascx that is included in Site.Master in asp.net mvc asp.net MVC-直接在aspx(site.master)中进行条件编译? - asp.net MVC - conditional compilation directly in aspx (site.master)? 根据用户ASP.NET MVC 3修改Site.Master内部的部分视图 - Modifying a partial view inside of Site.Master according to user ASP.NET MVC 3 如何在ASP.NET Site.Master页面中显示HTML页面 - How to display a HTML page in an ASP.NET Site.Master page 为什么Asp.net MVC团队在Site.Master页面中选择“../../Content/Site.css”而不是“〜/ Content / Site.css”? - Why did Asp.net MVC team choose “../../Content/Site.css” rather than “~/Content/Site.css” in Site.Master page? 无法在asp.net中修改Site.Master - Can't modify Site.Master in asp.net ASP.NET在site.master页中未评估C#代码 - ASP.NET no evaluation of C# code in site.master page asp.Net C#site.Master-排除Default.aspx页? - asp.Net C# site.Master - Exclude Default.aspx page? ASP.NET以编程方式从内容页更改Site.Master锚点 - ASP.NET Change Site.Master anchor from Content Page programatically 更改默认VS2012 ASP.Net Site.Master页面中的链接外观 - Changing link appearance in Default VS2012 ASP.Net Site.Master page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM