I am working on a project, I have 2 controllers: AccountController, Table_1Controller. On the Account controller, I returned a view with the path to the other controller's view. When I run the view of AccountController it returns the Table_1Controller but the URL is https://localhost:44365/Account/Verify. I don't get why it cant return https://localhost:44365/Table_1/Create. Can someone help me fix this?
AccountController.cs :
namespace LoginApp.Controllers
{
public class AccountController : Controller
{
private const string OtherController = "~/Views/Table_1/Create.cshtml";
SqlConnection con = new SqlConnection();
SqlCommand com = new SqlCommand();
SqlDataReader dr;
// GET: Account
[HttpGet]
public ActionResult Login()
{
return View();
}
void connectionString()
{
con.ConnectionString = "private;";
}
[HttpPost]
public ActionResult Verify(Account acc)
{
connectionString();
con.Open();
com.Connection = con;
string v = @"SELECT * FROM Table_Login WHERE Username = '" + acc.Name + "' and Password ='" + acc.Password + "'";
com.CommandText = v;
dr = com.ExecuteReader();
if(dr.Read())
{
con.Close();
return View(OtherController);
}
else
{
con.Close();
return View("Error");
}
}
Table_1Controller:
/Account/Verifyurl. You might want to return redirect instead.