DNN link two razor pages - c#

I am currently developing a razor module to DNN (Dotnet Nuke). In that I want to add a link to my main cshtml page to redirect another cshtml page with a parameter which located in the same folder. Could anyone suggest me a solution for that.
Thank you,
Nayanajith

User a querystring parameter to do that.

Related

How to create single page and render many pages in ASP.net

i want to create an ASP.NET website, what i want to do is to create a page lets name it the main page "main.aspx", not MVC or razor pages.
Then inside this page i control and render the other pages using paramter in the url named "method" for example as following :
main.aspx?method=register : so the register page or view rendered in the main page.
main.aspx?method=users : the users page or view rendered in the main page.
My question is, what it the right choice to do this in Visual studio 2017 ?
if web forms is the right one, what is the main page should be "Default.aspx" or another page ? where i should exactly get the "method" value ? where i should put the template or the view of the "register" for example? and what is the expected content to be inside it ?
It sounds like you want a Single Page Application type of site.
My question is, what it the right choice to do this in Visual studio 2017 ?
Sure it is, if you understand what you are building. Try creating a new ASP.NET Core project with the SPA template, and see if that is what you are looking for. If so, I would strongly suggest checking out the [ASP.NET SPA Documentation(https://learn.microsoft.com/en-us/aspnet/web-api/overview/getting-started-with-aspnet-web-api/build-a-single-page-application-spa-with-aspnet-web-api-and-angularjs)..
If you use Webforms, the template that can wrap other pages is called a MasterPage.
You don't need to pass the page name through a querystring, though. You can accomplish that with the URL Rewrite module or with Routing, but neither is necessary. The MasterPage will wrap any page that uses it automatically.
Here's an overview:
ASP.NET Master Pages
https://msdn.microsoft.com/en-us/library/wtxbf3hh.aspx

How to open MVC5 view from aspx page

Ive got an aspx file on the root of web application MVC5 project. I can go from Mvc View to the aspx file but im stuck on going back to mvc view. How do i go back from button event in Aspx? Fyi, this is just an empty project as im trying to learn on MVC. So everything is left as it is. Default configuration. The only difference that ive made is add redirect to the aspx page inside Home controller ActionResult.
Folder Structure and redirect code.
p/s. If you are wondering why i used an aspx file inside my mvc, im trying to do dynamic rdlc reporting using reportviewer. Im not sure if it could be done using mvc view. As far as i know, razor engine could not use reportviewer and thats why i use an aspx file. Im probably wrong on this as im still very new in doing MVC. Tqvm in advanced.
Try this:-
First change your current code
public RedirectResult Report()
{
return Redirect("~/ReportWebForm.aspx");
}
And in your .aspx page, add
Response.Redirect("/Controller/Action")

Layout Page not rendering Some Pages Asp.net MVC5

i am trying to develop MVC5 applicaiton. i am facing a problem. i have set a layout page placed in shared folder. Home pages of all controls are working properly.
but other pages are not showing in proper way.
I have attached a sample page Details
I checked css is also showing in source but page is not displaying in proper way
Thanks in advance. i am new in MVC
If you open your browser's Developer Toolbar and review the network tab you should be able to see if your pages are returning 404 for the files. When your browser is open press F12 and the toolbars should open.
It looks to me like your references to your local/application based stylesheets/javascript are missing the tilde symbol ~ at the beginning which means in ASP.NET the server-side application root.
For example ~/Content/bootstrap.css would be translated to the URL of the bootstrap.css file that's in the application's root.
You can drag and drop the bootstrap.css file in your content file into the _layout.cshtml file to see the correct path for the href attribute.
Put the sympole ~ before the link of css path

How to manually servce a .cshtml file without a controller?

Is it possible to create a .cshtml file (Razor) and process it manually? I would like to link to a page that does not currently have a controller, yet display a .cshtml page as a result. How would this be possible?
Not sure if its what you need, but Microsoft recently added something like this to the ASP.Net product line where you could use just Razor marked up web pages, and funnily enough they called it ASP.Net Web Pages.
http://www.asp.net/web-pages

Load views from location outside the mvc website

I'm trying to load an MVC view form a folder outside the location of the app.
My app is in C:\dev\myproject\ and the view file i'm trying to load is located in D:\viewsfolder\something is it possible to do that?
I tried passing an absolute path to the return View() method but that didn't work.
This is not supported by standard ASP.NET MVC. You may take a look at the RazorEngine plugin which allows you to render a Razor view from a string.
You haven't really explained why you need to do that by the way. Maybe there's a better approach to your particular problem.
The best way to do this is to have your Views Precompiled into a dll which can be used across multiple locations with only one code base.
This can be done using the Razor Generator Plugin which you can find here:
http://razorgenerator.codeplex.com/

Categories

Resources