.Net web application behind WebSeal reverse proxy

We are currently developing a solution that will run as a .Net application through the WebSeal reverse proxy server.

I saw some comments on the net where people had various problems with this, like rewriting viewstate.

Question: Has anyone implemented this combination of technologies and got it to work?

+3
source share
2 answers

Initially, I have some problems with the ASP.Net application when accessing via WebSeal. I ran the site on the development server. What worked for me was to deploy the application with debugging disabled in the configuration file.

<compilation debug="false" ...>

AJAX, , , WebSeal. , .

, WebSeal , Windows.

+2

ASP.NET, WEBSEAL. .

, :

IIS ASP.NET

( "... Login.aspx" "... login.aspx" ); webseal . , WEBSEAL - (, javascript, )

, URL- ,

WEBSEAL , , .   , URL- , URL- , (WEBSEAL ) (WEBSEAL , ). - URL- .
HTML, <.. href=/ anything>: URL- , .
Code Behind, "= ~/ anything", . "= / anything" ResolveUrl(..), .

: AJAX JavaScript ScriptResource.axd WebResource.axd URL- , . , .
( ): WEBSEAL .
: ( )

protected void Page_Load(object sender, EventArgs e)
    {
        //Initialises my dirty hack to remove the leading slash from all web reference files.
        Response.Filter = new WebResourceResponseFilter(Response.Filter);
    }

public class WebResourceResponseFilter : Stream
{
    private Stream baseStream;

    public WebResourceResponseFilter(Stream responseStream)
    {
        if (responseStream == null)
            throw new ArgumentNullException("ResponseStream");
        baseStream = responseStream;
    }

    public override bool CanRead
    { get { return baseStream.CanRead; } }

    public override bool CanSeek
    { get { return baseStream.CanSeek; } }

    public override bool CanWrite
    { get { return baseStream.CanWrite; } }

    public override void Flush()
    { baseStream.Flush(); }

    public override long Length
    { get { return baseStream.Length; } }

    public override long Position
    {
        get { return baseStream.Position; }
        set { baseStream.Position = value; }
    }

    public override int Read(byte[] buffer, int offset, int count)
    { return baseStream.Read(buffer, offset, count); }

    public override long Seek(long offset, System.IO.SeekOrigin origin)
    { return baseStream.Seek(offset, origin); }

    public override void SetLength(long value)
    { baseStream.SetLength(value); }

    public override void Write(byte[] buffer, int offset, int count)
    {
        //Get text from response stream.
        string originalText = System.Text.Encoding.UTF8.GetString(buffer, offset, count);

        //Alter the text.
        originalText = originalText.Replace(HttpContext.Current.Request.ApplicationPath + "/WebResource.axd",
            VirtualPathUtility.MakeRelative(HttpContext.Current.Request.Url.AbsolutePath, "~/WebResource.axd"));
        originalText = originalText.Replace(HttpContext.Current.Request.ApplicationPath + "/ScriptResource.axd",
            VirtualPathUtility.MakeRelative(HttpContext.Current.Request.Url.AbsolutePath, "~/ScriptResource.axd"));

        //Write the altered text to the response stream.
        buffer = System.Text.Encoding.UTF8.GetBytes(originalText);
        this.baseStream.Write(buffer, 0, buffer.Length);

    }

"/WebResource.axd" "ScriptResource.axd" "../../WebResource.axd" "../../ScriptResource.axd"

WEBSEAL

WEBSEAL , HTTP_IV_USER. Webseal\Login.aspx, . , CurrentUser, asp.Login

<span style="visibility:hidden"> 
<asp:Login ID="Login1" runat="server" DestinationPageUrl="~/Default.aspx">..

protected void Page_Load(object sender, EventArgs e)
{
    string username = Request.ServerVariables["HTTP_IV_USER"];
    (Login1.FindControl("Password") as TextBox).Text = MyCustomProvider.PswJump;
    if (!string.IsNullOrEmpty(username))
    {
        (Login1.FindControl("UserName") as TextBox).Text = username;
        Button btn = Login1.FindControl("LoginButton") as Button;
        ((IPostBackEventHandler)btn).RaisePostBackEvent(null);
     }
    else
    {
        lblError.Text = "Login error.";
    }
}

LoginButton, UserName ( WEBSEAL) ( ). , , .

web.config

loginUrl - URL- , FormsAuthentication. WEBSEAL: .

<authentication mode="Forms">
  <forms loginUrl="https://my.webseal.portal/" defaultUrl="default.aspx"...."/>
</authentication>

Webseal/login.aspx , :

<location path="Webseal/login.aspx">
    <system.web>
        <authorization>
            <allow users="*"/>
        </authorization>
    </system.web>
</location>

:

 <membership defaultProvider="MyCustomMembershipProvider">
  <providers>
    <add name="MyCustomMembershipProvider" type="MyNamespace.MyCustomMembershipProvider" connectionStringName="LocalSqlServer"/>
  </providers>
</membership>
<roleManager enabled="true" defaultProvider="MyCustomRoleProvider">
  <providers>
    <add name="MyCustomRoleProvider" type="MyNamespace.MyCustomRoleProvider" connectionStringName="LocalSqlServer"/>
  </providers>
</roleManager>

:

<compilation debug="false" targetFramework="4.0">

, !

+8

Source: https://habr.com/ru/post/1765779/


All Articles