简体   繁体   English

创建页面的新实例并获取URL

[英]Create new instance of a page and obtain URL

i'm a beginner web programmer. 我是一个初学者的Web程序员。 I've been coding desktop applications primarily. 我主要是在编写桌面应用程序的代码。 Right now, i have created this web app, in Silverlight, that uses a web service of my own for querying the database. 现在,我已经在Silverlight中创建了这个Web应用程序,它使用我自己的Web服务来查询数据库。 The thing is, one of the app functionalities is the ability to open PDF files. 问题是,应用程序功能之一就是能够打开PDF文件。 I know that silverlight won't let you do this, but using an IFrame on top of the silverlight application you are able to display a page with de pdf file (using acrobat plug in). 我知道Silverlight不允许您这样做,但是在Silverlight应用程序的顶部使用IFrame可以显示带有de pdf文件的页面(使用acrobat插件)。 So here's the problem, my silverlight app passes the pdf path to the web service and, in return, the web service would create a new Page and pass the new page URI back so that it can be displayed on the IFrame: 这就是问题所在,我的silverlight应用程序将pdf路径传递到了Web服务,作为回报,Web服务将创建一个新的Page并将新的页面URI传递回去,以便可以将其显示在IFrame上:

Page Code Behing: 页面代码行为:

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 Code: WebMethod代码:

    [WebMethod]
    public string GetReport(string filename)
    {
        PDFViewer viewer = new PDFViewer(filename);

        return viewer.Uri.AbsoluteUri;
    }

this only returns the Web service URL. 这仅返回Web服务URL。 So the main question is: How to create a page instance and obtain that page URL? 因此,主要问题是:如何创建页面实例并获取该页面URL?

The solution to this might be here: http://forums.silverlight.net/forums/p/76977/372282.aspx 解决方案可能在这里: http : //forums.silverlight.net/forums/p/76977/372282.aspx

"In my Silverlight app i open a new web browser by passing in query string my id and the page process it, query the db, retrieve the selected object and renders with the response methods." “在我的Silverlight应用程序中,我通过输入查询字符串我的id来打开新的Web浏览器,然后页面对其进行处理,查询数据库,检索所选对象并使用响应方法进行渲染。”

I just don't know how to do it. 我只是不知道该怎么做。

Any help is greatly appreciated. 任何帮助是极大的赞赏。

Pedro 佩德罗

Maybe this will help. 也许这会有所帮助。

wherever your silverlight object is embedded put an iframe with id="xContainer" 无论将Silverlight对象嵌入到何处,都将iframe设置为id =“ xContainer”

and from your silverlight code just set its scr to the pdf you're trying to display 然后从您的Silverlight代码中将其scr设置为您要显示的pdf

HtmlPage.Document.GetElementById("xContainer").SetProperty("src", "http://google.com");

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM