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
Related
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
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")
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.
I'm currently migrating my site from .aspx to .cshtml.
With my old site, a few of my pages required interaction between javascript and the server through webmethods. This was easily achieved, you simply define a webmethod in the code behind of the .aspx page, then post to it at URL = [page path].aspx/[function name].
I've done quite a bit of looking around, but haven't been able to determine whether an equivalent process is possible with a .cshtml page.
So far I've worked around this by producing a folder with .aspx pages whose sole purpose is to provide these webmethods.
Obviously I'd like to get rid of these. Is this a feature with razor?
I have some pages written in cshtml but they don't use any of the razor features. Basically they use knockout javascript and then query MVC controller methods for get and post.
I don't want to use any WinForms features, I just want to make AJAX calls.
I want to use these pages in a WebForms project but want to know if there are any issues with just using plain .html files inside a WebForms project. Will this cause any major issues with the Web Forms project? Can I still reference a MasterPage?
You can use HTML files in you WebForms project as well in ASP.Net MVC project as long as you don't need any server side processing of such files...
But using master pages requires server side processing, so plain HTML files would not work for that.
As an option you can use such files in IFrame rendered by regular ASPX page or just include all content onto ASPX page (read file and write without encoding).