cancel
Showing results for 
Search instead for 
Did you mean: 

.Net connector Login - Invalid Connection String

Former Member
0 Kudos

Hi,

My company is using sap R/3 4.6c and VS.Net 2003. I am trying out the example as provided in the SAP .Net Connector document to connect from .Net web application to SAP. I have followed the steps in the example to create sap proxy, SAPLogin1.aspx and drag in the Connect code from the SAP proxy toolbox. I get the error Invalid Connection String at the coding "SAP.Connector.SAPLoginProvider.GetSAPConnection(this);" when I clicked the button. Based on the document, I am supposed to be redirected to SAPLogin1.aspx. Appreciate any help and advise.

Regards

Accepted Solutions (0)

Answers (1)

Answers (1)

reiner_hille-doering
Active Contributor
0 Kudos

Sometimes you don't get redirected to logon. In those cases you need to modify the <authorization> section in Web.config. It should contain <deny users="?" /> - so uncomment it. It shouldn't contain anything else.

Former Member
0 Kudos

Thank you. Can I make use of the SAP.Connector.SAPLoginProvider.OpenSAPConnection to auto connect to sap in the program as I want to run it as a background program? If I am using OpenSAPConnection, do I still need to use GetSAPConnection ?

regards

reiner_hille-doering
Active Contributor
0 Kudos

I don't understand the question, but here's what SAPLoginProvider does:

OpenSAPConnection opens a connection on the given connection string and stores it (the Connection) into Session state. Also it will tell Microsoft's Form Authentication Provider, that the user is authenticated. As a result it will store a cookie on the client machine.

GetSAPConnection will try to get the connection from Session state. If it fails, it will try to create a new connection based on the data in the cookie. If this also fails, it will inform the Microsoft Forms Login Provider that the user is not logged in anymore. This will usually cause a new Redirect to the login page.

CloseSAPConnection will close the connection is session state and tell Microsoft' Forms Authentication provider that the user is logged out.

Former Member
0 Kudos

I haven't understood well which is the best place to put the call to CloseSAPConnection() in an Asp.Net (perhaps) basic scenario, where a single connection is used for the whole user session activity;

I thougt about the Session_End event: if it's the case, what should I pass to the CloseSAPConnection() method?

thank you.

reiner_hille-doering
Active Contributor
0 Kudos

This is an excellent question.

In the original design, we assumed that everything should work automatically: At session end the SessionModule would automatically Dispose all objects in the session state - which would close the connection.

In fact I have heard of cases where this doesn't work as expected.

A possible workarround would a code snipped like the following:

protected void Session_End(Object sender, EventArgs e)

{

SAPConnection conn = this.Session[SAPLoginProvider.SAP_CONNECTION] as SAPConnection;

if (conn != null)

{

conn.Close();

this.Session.Remove(SAPLoginProvider.SAP_CONNECTION]);

}

}

Calling CloseSAPConnection would have a similar effect, but you could not call it here as it needs a page as parameter. And it would also try to sign out the user from the MS FormsAuthenticationProvider (which doesn't make a lot of sense at session end.

Anyway, Microsoft doesn't guarantee Session_End to be called at all. Therefore we have changed the design of SAPLoginProvider in NCo 2.0: Here we don't store the Connection in session state, but only the connection string / Destination. The connection itself would be stored in Connection Pool. The Pool has a timeout behavior that we consider being more reliable than the Session_End timeout.

Former Member
0 Kudos

is the new behavior included in published NCo 2.0 beta (which I'm currently working with) or will it be included on next release?

additionally, I'd like to ask when you plan next beta release, but I usually get bored by such questions from clients, so...

reiner_hille-doering
Active Contributor
0 Kudos

It's in the version you use. So you don't have to care about closing the connection.

There will not be "a next Beta". Consider it as Release Canditate. The Final version will be out in September or October.