Mvc 3 & cms

r3plica

Member
Joined
Dec 22, 2011
Messages
11
Programming Experience
5-10
Hey all,
I have searched the internet and have found no solution.
I have downloaded loads of CMS's created using the MVC framework to no avail.
So, in desperation, I come here.

I am currently creating a CMS using the MVC framework and so far everything is working out fine.
I have now gotten to the stage of serving up the pages that are created in the admin area and I have hit a brick wall.
I have a controller called CmsController, which get's the URLRefferer and find's it in the existing pages. If it doesn't exist, I returned a 404, but if it does I serve up the content.
My issue is that I want to return the old URL and serve the content to that.
Obviously these pages do not exist, they are dynamic, so they have no supporting Controllers. Does anyone know how I can still serve up the content to a ficticious URL?

cheers,
r3plica
 

dr-snipe

Member
Joined
Jan 25, 2012
Messages
7
Programming Experience
3-5
Did you mean if someone has a query of page.php?q=29041..... or something like that, how do you respond?
 

r3plica

Member
Joined
Dec 22, 2011
Messages
11
Programming Experience
5-10
Not really.
What I have is basically a database that holds the information for the pages (i.e. the content and it's virtual path).
So a menu is created on the template (Layout.cshtml) which links to where these pages would be if they existed.
For example /Guides/Test/.
What I need is for the application to check the pages stored in the database for a match for the Url and then display the page without changing the URL.

What I have done since this post is create a class derived from VirtualFile and overridden the GetFile method to check my pages and return true. If they are not in the database then use the base.GetFile method.
This works if I call Cms/Index/<PageId> which is the central location for getting a page with an ID.
I need it to work if they use the virtual path instead.

I tried using a catch all route, but when you redirect to a controller and action it updates the URL. That is no good.
 

dr-snipe

Member
Joined
Jan 25, 2012
Messages
7
Programming Experience
3-5
Oh so you don't want the client to be able to see the full address?

You could have the .cshtml file have an iFrame inside of it where the client clicks the links to the pages that you have stored in the database. That way the URL of the browser does not change but the URL of the iFrame does, but it is not easily viewable. Would that work?

I'm not familiar with C# and web development but that might be a solution to what you're problem.
 
Top Bottom