Register now or log in to join your professional community.
Hello everyone,
I have three (3) problems with MVC WebApplication
I will give an example to make you understand my question.
Suppose two Database-Tables (Departments & Students). Student-Table has student related properties with DepartmentId.
Problem #1:
I want to retrieve Student records in an HTML-Table along with DepartmentNames from Department-Table (Database-Table) instead of DepartmentId.
So what should I do in the Controller and in the View?
_
Problem #2:
Consider the above example:
I want to rewrite my URLs in a friendly manner, e.g. If I navigate to StudentsList actionMethod in Student controller which lists students, then from there I click on a particular student to navigate to the details view, so my URL will look like,
Student/Details/4
here "Student" is Controller,
"Details" is ActionMethod,
and "4" is the StudentId. Thats fine, but I want it like this,
StudentsList/Details/Jehangir-Wahid
here "StudentList" is an ActionMethod,
"Details" is another ActionMethod,
and "Jehangir-Wahid" is the selected StudentName against StudentId =4.
so how can I map a route like this?
_
Problem #3:
Consider the above example:
I want to #Tokenize my Post-Request to the server using session, so what should I do?
_
If anyone know how to solve atleast one of the mentioned problems, then please help me with it.
Thanks for your kind considerations.
I'm not sure if my answer would be what you're really looking for, but this is what I would suggest for:
Problem #1:
It's all based on the SQL Statement to retrieve the exact information you need
Select DepartmentName from Department-Table where DepartmentID = "DepIT"
Problem #2:
What you're looking to achieve is a Simple URL. To do so, you'll need to go through URL Rewriting.
Requirements:
- IIS 7 or above with role ASP.NET enabled
- URL Rewrite module enabled
You'll need to build a Rewrite handler that will "Search" and "Replace"
Here's how to create a Rewrite Rule:
http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module
Problem #3:
I assume you want to use the Tokens for login. If that's the case, here's an article with the code on how-to implement
http://www.dotnetcurry.com/aspnet/1223/secure-aspnet-web-api-using-tokens-owin-angularjs
Hope this answers your question, or at least, a partial answer to your question.