This question already has answers here:
MVC Rendering (RenderPartial, RenderAction) Html from another MVC Application
(2 answers)
Closed 5 years ago.
I have 2 applications published in the same site in iis, so the only diference between both is the virtual path, ex: localhost:2020/app1 and localhost:2020/app2. My problem is that in the app1, I want to call a partialView from the app2 and I can't add the references from the app2 to the app1. Any idea how to do that?
The only reasonable way (to me at least) to do this is to move shared partial views to separate library and use RazorGenerator tool to generate code for them. Then when you will reference the library in web projects of both applications those views will be available to use.
Related
This question already has answers here:
How to solve circular reference?
(6 answers)
vs2008 circular references (c#)
(6 answers)
Resolving Circular References (C#)
(6 answers)
Closed 4 years ago.
So I have many projects in my solution.
AppName
AppName.Game
AppName.Common
AppName.Core
I'm currently hosting networking in AppName.Common because AppName requires it to initialize it, and AppName.Game requires certain classes from it to store propertys based on them classes.
The problem comes when I can't reference AppName.Common and AppName.Game both ways. Common requires the Game's classes to know what to call when a new packet comes in, and the game project needs the networking (DotNetty) to use the classes for the propertys.
I can't see why Microsoft have blocked referencing both ways, it seems like such a struggle to get to where you want to be? Is there any workaround for this?
The simplest and best way to do what you need is to move the code that both projects need somewhere that they can both access without having a circular reference. Add another project to your solution:
AppName.Networking
Put all the network stuff that both projects need into that and reference it.
This question already has answers here:
What is the different between System.Web.Http.HttpPut Vs System.Web.Mvc.HttpPut
(2 answers)
Closed 3 years ago.
In my Web API project which is based on the ASP.NET MVC, I want to use the HttpPost attribute. When I've added that onto the action, The IntelliSense suggests me these two namespaces:
System.Web.Mvc.HttpPostAttribute
System.Web.Http.HttpPostAttribute
Which one should be used and why?
Prior to ASP.NET Core, MVC and WebAPI were mainly separate libraries.
The .Mvc namespace applies to MVC controllers, the .Http namespace to Web API controllers.
This question already has answers here:
Render Razor view to string in ASP.NET 5
(2 answers)
Closed 7 years ago.
After a long search for a solution to this problem, I only found MVC5 and outdated solutions.
Now that we are in asp.net 5 beta 7, there are any way to render a view to a string variable ?
I need to render a view to show it in a bootbox javascript control (like a modal windows).
The MVC 5 solutions does not work in version 6 because there is no "ViewEngine" class in there. Look:
and even the Razor object canĀ“t be found:
You can use this approach (see RenderPartialViewToString):
https://stackoverflow.com/a/32577016/2631076
This question already has answers here:
Is it possible to make an ASP.NET MVC route based on a subdomain?
(10 answers)
Closed 8 years ago.
I'm writing here becouse one question doesn't let me sleep calmly. How it's possible that site www.visualstudio.com when I sign in to free TFS account, create special 'part' of site with url {myprojectname}.visualstudio.com?. Is it achieveable in my project using ASP.NET MVC 4 or 5? How it doesn't affect in current DNS system? or it affect? What should I read to let my site be so deeply customizable?
for example:
user1.mysite.xx
user2.mysite.xx/aaa/4/sda/something_other
The easiest way is to define a wildcard DNS A or CNAME entry like (BIND syntax):
*.myside.xx. IN A x.x.x.x
In Windows you can use the command line dns tool for it: http://support.microsoft.com/default.aspx?scid=kb;en-us;840687
After that regardless what you write as username.myside.xx it will hit your webserver. From your code you can decide what to do, make a redirect to username.myside.com/username or whatever else
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How do you avoid XSS vulnerabilities in ASP.Net (MVC)?
Hi I need to create a guest book, where users can add their comments and have theme being displayed without moderation on a page.
I'm using Asp.Net MVC 3 in C#.
Could you point me out some tecnics? thanks
Thanks for your time.
PS I'm using Razor
Just make sure all user generated content is HTML encoded before you write it to the browser and you'll be fine. Razor view engine does this by default... it's actually quite hard to screw up on this using Razor.
So:
#"<script>badness</script>"
in Razor would render in HTML as
<script>badness%lt;/script>
to achieve the same in ASP.NET view engine use <%:expression%> as opposed to <%=expression%>
<%:"<script>badness</script>"%>
You could you the AntiXSS library. This is mentioned by:
http://weblogs.asp.net/jgalloway/archive/2011/04/28/using-antixss-4-1-beta-as-the-default-encoder-in-asp-net.aspx
http://haacked.com/archive/2010/04/06/using-antixss-as-the-default-encoder-for-asp-net.aspx