I'm having trouble with the navigation in asp.net mvc and handling URLs.
For example, when you visit your profile on Facebook, the URL is facebook.com/yourusername. On your profile page, there is a menu with links such as Timeline, About, Friends, etc.
If you click on a link like Photos
, the URL changes to facebook.com/yourusername/Photos, and the photos are displayed. The menu remains visible, along with the profile picture and cover photo. It's almost like a partial view has been rendered for viewing the photos.
I would like to achieve this same effect in my project, but I'm not sure how to implement it. I have tried using Partial view
, but the problem is that the URL does not change when the partial view is rendered.
How should I structure this in my project?
Here is an example of what my Index.cshtml file, belonging to the Home-controller
, looks like:
<div class="centering col-lg-7 logged_in_mainboxes" style="padding: 0; position: relative">
<div class="col-lg-12 coverPicture" style="background-image: url('/Content/Images/@Model.CoverPicture');">
<div id="image-cropper">
<div class="cropit-preview"></div>
<h3 class="coverPicTextStyle">
@Model.Name
</h3>
<button type="submit" id="uploadCoverpicture" class="btn_style_2 btn" style="position: absolute; bottom: 10px; right: 10px;">Upload</button>
<button type="submit" id="crop" class="btn_style_2 btn" style="position: absolute; bottom: 50px; right: 10px; display: none;">Done</button>
<input type="file" class="cropit-image-input" id="coverUpl" style="display: none;" />
</div>
<div class='progress' id="progress_div">
<div class='bar' id='bar1'></div>
<div class='percent' id='percent1'></div>
</div>
<input type="hidden" id="progress_width" value="0">
</div>
<div class="col-lg-12 pull-left">
<div class="user_menu">
<ul>
<li>@Html.ActionLink("Wall","Wall","Home")</li>
<li>@Html.ActionLink("Music", "Music", "Home")</li>
<li>@Html.ActionLink("Photos", "Photos", "Home")</li>
<li>@Html.ActionLink("Videos", "Videos", "Home")></li>
<li>@Html.ActionLink("About", "About", "Home")</li>
</ul>
</div>
</div>
<div class="col-lg-7 pull-left" style="margin-top: 15px;">
</div>
<div class="col-lg-3 pull-right" style="border-left: 1px solid #ddd; margin-top: 15px; ">
asdasd
</div>
</div>