0

I am confused how to create my login session with following layout of my page.

  1. I have a HTML page which consist of table data Insert, Update, Print, Delete options. Now I would like to create a login session to get access to this options I don't know how to do that. If I had a webform containing this web form I didn't had problem but this is a HTML page (requirement) to create first session then go on to next step which selecting these options.
  2. I have multiple database in my server to I also have to create dropdown list to select this specific database.

Is there any solution to this. Also I have my connection string from web.config which creates the session.

Layout:

HTML file which have above list option to alter your database including login script which gives access (let's call this as index.html). Now when I login with above query all this options gets activated and I am able to go to this 4 web forms.

I have 4 web forms which is .aspx(related to Insert, Update, Print, Delete).

web.config

    <?xml version="1.0"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
<appSettings>

    <add key="SQLConn" value="Data Source=server name;Initial Catalog=database name;Persist Security Info=True;User ID=ID;Password=password" />


  </appSettings>
    <system.web>
      <compilation debug="true" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5" />
    </system.web>

</configuration>

Now I don't know how to program this which creates session for both HTML and aspx pages.

  • Why does it have to be a HTML page? Technically .aspx pages end up as HTML once they are on the client... – Ravendarksky Apr 16 '14 at 14:52
  • I have a requirement like that I can't change it. –  Apr 16 '14 at 14:52
  • Can you elabourate please? Are you trying to develop a solution for a customer who isn't using webforms only HTML? What part of the requirement is mandating the inability to change it. – Ravendarksky Apr 16 '14 at 14:54

2 Answers2

0

You can use either ASP.NET Universal Providers or ASP.Net Identity.

It will let you create a role based authentication.

Basically, you place the html inside a folder. In the folder, you create a web.config like this.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <authorization>
      <allow roles="Administrators" />
      <deny users="*"/>
    </authorization>
  </system.web>
</configuration>

If you think Membership Providers are very heavy for your appliation, you can hand-roll your own authentication like this.

FYI: If you have a question regarding Membership Providers, please search in SO first before creating a new question.

Community
  • 1
  • 1
Win
  • 61,100
  • 13
  • 102
  • 181
  • I do have web config file but can how can I call that in HTML to give access to aspx page –  Apr 16 '14 at 14:56
  • IPricipal object will take care of the authentication and authorization. The topic of IPricipal itself is very large; if you are new to IPrincipal object, I won't be able to answer in a single question. Instead, you need to read the articles included in my answer. If you have specific question, search in SO or come back and ask again. – Win Apr 16 '14 at 15:01
0

To answer the first question:

Save a cookie locally, lets say "login=true" check if this cookie named "login" contains a value of "true". Once checked, show the options for the table in JQUERY. For instance, hide the div that contains these options after you check if the cookie has the value "true"

This is not the best way to deal with login issues. You should build a page that checks the session at the server side and this page should be a ASPX page.

Second question:

Create two connection strings. Check if dropdown value "A" was selected, and access the database using the first connection string, if "B" was selected, use the second connection string.

Basilf
  • 401
  • 5
  • 17
  • For second question I have web form with drop down menu which I trying to code in code behind which I don't know how to start –  Apr 16 '14 at 15:04