0

I am developing a project having two controllers named as "Student" and "Profile".

public class StudentController : Controller
{
    public ActionResult Login(){}
    public ActionResult Home(){}

} 

public class ProfileController : Controller
{
    public ActionResult Details(){}
} 

When I am at my Home page after login, it gives me the following url

url:http://localhost:3451/Student/Home?username=student%40gmail.com

and when I click on Ajax based Profile link give below

@Ajax.ActionLink(" ", "Details", "Profile", 
                new { username = Session["username"].ToString() }, 
                new AjaxOptions() 
                { 
                 UpdateTargetId = "ajax",
                 InsertionMode = InsertionMode.Replace, 
                 HttpMethod = "POST", 
                 OnSuccess = "changeUrl(data)" }, 
                 new { @class = "glyphicon glyphicon-user", 
                 title = "Profile", style = "color:white;" 
                })

gives me the Student Profile but url remains same but I want the url to be changed something like that

url:http://localhost:3451/Profile/Details/
WasiF
  • 26,101
  • 16
  • 120
  • 128
  • So why not just post to that controller why use Ajax? – AliK Mar 13 '16 at 10:45
  • just to save server headache, so that server should not send the common hmtl/css again and again – WasiF Mar 13 '16 at 10:57
  • If it really is that much html/css being loaded then you could look into using the javascript location.hash to change url. – AliK Mar 13 '16 at 10:59
  • it is possible to change action name in the url but i wanna know that is it possible to change the controller name too ??? – WasiF Mar 13 '16 at 11:07
  • 1
    I think this is what you want. http://stackoverflow.com/questions/824349/modify-the-url-without-reloading-the-page – Rajshekar Reddy Mar 13 '16 at 12:48

0 Answers0