http://drew-prog.blogspot.com/2011/01/how-to-deploy-aspnet-mvc-3-app-to-web.html
Archive for the ‘Programming’ Category
How to Running an ASP.NET MVC 3 app on a web server that doesn’t have ASP.NET MVC 3 installed
Posted: August 23, 2011 in IDE, MVC 3, Programming, Visual Studio, Web ApplicationMy Favourite Visual Studio 2010 extension
Posted: August 18, 2011 in IDE, Programming, Visual StudioTags: ASP.NET, C#, Extension, MVC3, Visual Studio
For my web application project using ASP.NET MVC3 (C#), here is the list of my free favorite extensions:
- Indent Guides
- Javascript parser
- JScript Brace Matching Extension
- JScript Editor Extension
- JScript Outlining Extension
- JScript Word Highlighter Extension
- NuGet Package Manager
- Productivity Power Tools
- Spell Checker
- SQL Server Developer Tools, Codename “Juneau”
- VSCommands 2010
- Power Commands For Visual Studio 2010
- Web Standards Update for Microsoft Visual Studio 2010
- CSS 3 Intellisense Schema
- SQL Server Compact Toolbox
- ADO.NET C# POCO Entity Generator
- ReGex Editor (But somewhat buggy)
How to add Ninject to your project using Visual Studio 2010 SP1
Posted: August 18, 2011 in IDE, Programming, Visual StudioTags: .NET, C#, DI, IoC, MVC, Ninject
If you happen to reach this page, chance are you are facing what I just faced several minutes ago. Scratching my head to follow some programming book instruction (read: instruct me to add ninject by ‘Add Library Package Manager’ where I couldn’t find it).
I am not really sure what have changed between the author’s VS2010 and my current version. The fact is, ‘Add Library Package Manager’ somehow is not visible at my IDE. After several minutes of try and error, I manage to install Ninject by doing these steps:
- Right click on your project’s Reference in the Solution Explorer.
- Select Manage NuGet Packages.
- Click Online on the left side of the dialog.
- Search Ninject.
- Click Install button.
- Click on ‘I Accept‘ button.
- Done…. 😀
Note 1: Ninject can’t be added directly to Visual Studio in global manner due to its dependency on your project’s .NET version. Therefore, it has to be added on project basis.
Note 2: If your project has some compiling issue or problem, make sure your project use .NET framework version 4.
- Select project properties mkenu item under the Project Menu
- Change the Target Framework setting to .NET framework 4
ASP.net (VB.net) simple login page
Posted: November 12, 2009 in Programming, Visual BasicTags: login page, visual basic
Dim connStr As String = ConfigurationManager.ConnectionStrings(“MainConnStr”).ConnectionString
Dim sqlconnet As SqlConnection
Dim MyComm As SqlCommand
sqlconnet = New SqlConnection()
sqlconnet.ConnectionString = connStr
MyComm = New SqlCommand(“”, sqlconnet)
MyComm.CommandType = Data.CommandType.Text
MyComm.CommandText = “SELECT * FROM login WHERE (username ='” & txtUsername.Text & “‘) AND (password = ‘” & txtPassword.Text & “‘) ”
sqlconnet.Open()
Dim result As SqlDataReader = MyComm.ExecuteReader(Data.CommandBehavior.CloseConnection)
If result.HasRows = False Then
‘MsgBox(“login failed”)
‘Response.Write(“Fail”)
Lstatus.Text = “Your login or password doesn’t match. Login Fail”
Else
Session(“username”) = txtUsername.Text
‘MsgBox(“login success…!!!!”)
Response.Redirect(“success.aspx”)
‘Response.Write(“Success”)
End If
result.Close()
Servlet :
package com.arham.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.SQLException;
public class logincheck extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String username = request.getParameter(“username”).toString();
String password = request.getParameter(“password”).toString();
Connection connection = null;
try {
String driverName = “org.gjt.mm.mysql.Driver”; // MySQL MM JDBC driver
Class.forName(driverName);
String serverName = “localhost”;
String mydatabase = “arhamjava”;
String url = “jdbc:mysql://” + serverName + “/” + mydatabase; // a JDBC url
String sqlusername = “root”;
String sqlpassword = “MyP@SsW0rD”;
connection = DriverManager.getConnection(url, sqlusername, sqlpassword);
}
catch (ClassNotFoundException e) {
// Could not find the database driver
}
catch (SQLException e) {
// Could not connect to the database
}
Statement stmt = null;
ResultSet rs = null;
String checkUsername = null;
String checkPassword = null;
int checkAccessPower = 0;
try
{
stmt = connection.createStatement();
rs = stmt.executeQuery(“SELECT username, password, accesspower FROM account WHERE username = ‘” + username + “‘ AND id > 0”);
PrintWriter out2 = response.getWriter();
while(rs.next())
{
checkUsername = rs.getString(“username”);
checkPassword = rs.getString(“password”);
checkAccessPower = rs.getInt(“accesspower”);
}
if(checkUsername != null)
{
if(checkPassword.equals(password))
{
out2.println(“Welcome ” + username + “<br/> <h2>Login Success</h2>”);
if(checkAccessPower > 150)
out2.println(“Status : ADMIN”);
else if (checkAccessPower > 50)
out2.println(“Status : Normal User”);
else if (checkAccessPower < 9)
out2.println(“You have been banned by admin. Contact your administrator for clarification”);
}
else
out2.println(“<h1>Login Fail</h1> <br/> Click back to relogin!”);
}
else
out2.println(“<h2>Login Fail</h2> <br/> Reason : Your username not exist in our database.”);
}
catch (SQLException ex)
{
// handle any errors
System.out.println(“SQLException: ” + ex.getMessage());
System.out.println(“SQLState: ” + ex.getSQLState());
System.out.println(“VendorError: ” + ex.getErrorCode());
}
response.setContentType(“text/html;charset=UTF-8”);
PrintWriter out = response.getWriter();
try {
out.println(“<html>”);
out.println(“<head>”);
out.println(“<title>Servlet Login Check </title>”);
out.println(“</head>”);
out.println(“<body>”);
out.println(“</body>”);
out.println(“</html>”);
} finally
{
out.close();
}
}
// <editor-fold defaultstate=”collapsed” desc=”HttpServlet methods. Click on the + sign on the left to edit the code.”>
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
public String getServletInfo() {
return “Short description”;
}// </editor-fold>
}
***********************************************************************************