【发布时间】:2010-08-06 09:37:41
【问题描述】:
我是一名初学者网络程序员。我主要编写桌面应用程序。 现在,我在 Silverlight 中创建了这个 Web 应用程序,它使用我自己的 Web 服务来查询数据库。问题是,应用程序功能之一是能够打开 PDF 文件。我知道silverlight 不会让您这样做,但是在silverlight 应用程序之上使用IFrame,您可以显示带有de pdf 文件的页面(使用acrobat 插件)。 所以问题来了,我的 silverlight 应用程序将 pdf 路径传递给 Web 服务,作为回报,Web 服务将创建一个新页面并将新页面 URI 传回,以便它可以显示在 IFrame 上:
页面代码行为:
public partial class PDFViewer : System.Web.UI.Page
{
string Filename = string.Empty;
public Uri Uri
{
get { return HttpContext.Current.Request.Url; }
}
public PDFViewer(string filename)
{
Filename = filename;
}
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = "Application/pdf";
Response.WriteFile(Filename); //Write the file directly to the HTTP content output stream.
Response.End();
}
}
WebMethod 代码:
[WebMethod]
public string GetReport(string filename)
{
PDFViewer viewer = new PDFViewer(filename);
return viewer.Uri.AbsoluteUri;
}
这仅返回 Web 服务 URL。 所以主要的问题是:如何创建一个页面实例并获取该页面的URL?
解决方案可能在这里: http://forums.silverlight.net/forums/p/76977/372282.aspx
“在我的 Silverlight 应用程序中,我通过传入查询字符串我的 id 和页面处理它来打开一个新的 Web 浏览器,查询数据库,检索所选对象并使用响应方法呈现。”
我只是不知道该怎么做。
非常感谢任何帮助。
佩德罗
【问题讨论】:
标签: c# asp.net silverlight web-services