How do I automatically enter another page from a Silverlight application?

I wrote a Silverlight page that acts as an account registration tool for an existing web application. Therefore, it collects user data and then sends it to the server through the WCF RIA service, which creates an account in the database.

Basically, I want to automatically register the user in the application when the service returns that the registration was successful, but I'm not sure how to do it.

My current thought is that if I can READ the username and password on an existing login page, everything will be all right. However, although I can find numerous examples of how to make an HTTP message from Silverlight, they basically seem to assume that I want to display the response in an existing Silverlight application - I do not, I want the Silverlight application to go away and I I want the logged-in application to appear as if I pressed the login button on the login page.

Something along the lines

HtmlPage.Window.Navigate(new Uri("http://mysite.com/Login.aspx", UriKind.Absolute));

except the possibility of publication.

I do not want to pass the username and password to querystring.

Does anyone know how I can do this? Or, if this is not the right approach, someone can point me in the right direction.

+3
source share
2 answers

( ) HTML, Silverlight. Silverlight DOM .

+1

, , .

aspx :

<form id="form1" style="height:100%" action="http://mysite.com/Login.aspx" method="post">
    <input type="hidden" id="username" name="username" />
    <input type="hidden" id="password" name="password" />
    <div>silverlight app</div>
</form>

Silverlight, , -:

private void Logon(string username, string password)
{
    HtmlElement usernameField = HtmlPage.Document.GetElementById("username");
    usernameField.SetAttribute("value", username);

    HtmlElement passwordField = HtmlPage.Document.GetElementById("password");
    passwordField.SetAttribute("value", password);

    HtmlPage.Document.Submit();
}

, , runat = "server" . , , , ViewState MAC ". web.config:

<pages enableViewState="false" enableEventValidation="false" viewStateEncryptionMode="Never" enableViewStateMac="false"/>

none . , HTML-, .

0

All Articles