我正在建设一个新项目。
我有一个名为" bootstrapper"的单独项目。包含IOC和WebActivator ..我的问题是包含WebActivator的类甚至没有在调试中加载!可能是我错过了什么?
[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(IocConfig), "RegisterDependencies")]
public class IocConfig
{
public static void RegisterDependencies()
{
//..........
}
}
答案 0 :(得分:6)
您的 <form action="conn.php" method="POST">
Username:
<input type="text" id="username" name="username" />
Password:
<input type="password" id="password" name="password" />
<input name="submit" id="submit" type="submit" value="Login" />
</form>
<?php
$success = "";
if(isset($_POST['submit']) == "Login" )
{
$username = strip_tags($_POST['username']);
$password = strip_tags($_POST['password']);
$error = array();
// Username Validation
if(empty($username))
{
$error[] = " Empty or invalid username ";
}
if(empty($password)){
$error[] = "Enter your password";
}
if(count($error) == 0){
$host = 'localhost';
$database_name = 'projett';
$database_user_name = '';
$database_password = '';
$connection=new MongoClient();
if($connection){
// Select Database
$database = $connection->$database_name;
// Select Collection
$collection = $database->reg_users;
$user_data= array("username" => $username,"password" => md5($pass));
$result = $collection->findOne($user_data);
if($result){
$success = "You are successully loggedIn";
header("Location: Articles.php");
}
} else {
die("Mongo DB not installed");
}
}
}
?>
项目对应于洋葱架构的最外层。这是唯一引用所有其他项目的项目。
使用if(isset($_POST['submit'])){
//getting post variable
$email=strip_tags($_POST['email']);
$pass=strip_tags($_POST['password']);
$confirm_pass=strip_tags($_POST['confirm_password']);
$username=strip_tags($_POST['username']);
$error = array();
if(empty($email) or !filter_var($email,FILTER_SANITIZE_EMAIL))
{
$error[] = " <h2> complete email </h2>";
}
if(empty($username)){
$error[] = " <h2> complete username ! </h2>";
}
if(empty($pass)){
$error[] = " <h2> complete your password </h2> ";
}
if(empty($confirm_pass)){
$error[] = " <h2> confirm password </h2> ";
}
if($pass != $confirm_pass){
$error[] = " <h2> password not same </h2> ";
}
if(count($error) ==0){
//database configuration
$host = 'localhost';
$database_name = 'projett';
$database_user_name = '';
$database_password = '';
//if you have database user name & password then connection may be
//$connection=new Mongo("mongodb://$database_user_name:$database_password@$dbhost");
//Currently we are connecting to mongodb without authentication
$connection=new MongoClient();
//checking the mongo database connection
if($connection){
//connection database
$databse=$connection->$database_name;
//connection à la collection reg_user
$collection=$databse->reg_users;
$query=array('username'=>$username);
//checking for existing user
$count=$collection->findOne($query);
if(!count($count)){
//Save the New user
$user_data=array('email'=>$email,'password'=>md5($pass),'username'=>$username);
$collection->save($user_data);
echo " <h2> Vous êtes inscrit avec succès ! </h2> ";
}else{
echo " <h2> Username already exists </h2> ";
}
}else{
die(" <h2> Database are not connected </h2>" );
}
}else{
//Displaying the error
foreach($error as $err){
echo $err.'<br />';
}
}
}
可以避免在Onion.Bootstrapper
中引用WebActivator
。将在应用程序启动前调用Onion.Bootstrapper
方法。
要实现这一点,您唯一需要做的就是确保将WebApplication
dll推送到RegisterDependencies
/ bin 目录((易于设置)使用post build动作或 OutputTo nugget包))。
答案 1 :(得分:0)
尝试在“项目”>“属性”>“应用程序”上取消选中“自动生成绑定重定向”。