asp.net-mvc

Map to wwwroot in ASP.Net 4?

青春壹個敷衍的年華 提交于 2021-02-18 22:22:51
问题 Is there an easy way to add a subdirectory in ASP.Net v4 Web API that would contain all of my client content? I have read a lot of articles today on virtual paths and routing, but nothing that quite describes this case. For example, I want to store my images under wwwroot so when the the app receives this request: http://myapp/img/logo.png It fetches wwwroot\img\logo.png to handle the request. Obviously, I don't want to have to map out every file or folder individually. There will be a Web

How to call multiple actions in View in ASP.NET MVC?

最后都变了- 提交于 2021-02-18 19:10:46
问题 Problem is: I am using a textbox to get a string q and want to pass it to 3 different actions in search controller. i.e. action1(string q), action2(string q) and so on Now syntax of my action: public ActionResult action1(string q) { var mydata = from p in fab //LINQ logic select new action1class { data1=p //assignment }; return View("_partialAction1", mydata); } Similarly there are two other actions. I am using 3 different actions because my LINQ logic gets data from 3 different sources so

How to call multiple actions in View in ASP.NET MVC?

时光毁灭记忆、已成空白 提交于 2021-02-18 19:10:04
问题 Problem is: I am using a textbox to get a string q and want to pass it to 3 different actions in search controller. i.e. action1(string q), action2(string q) and so on Now syntax of my action: public ActionResult action1(string q) { var mydata = from p in fab //LINQ logic select new action1class { data1=p //assignment }; return View("_partialAction1", mydata); } Similarly there are two other actions. I am using 3 different actions because my LINQ logic gets data from 3 different sources so

MVC CSS on view page (not _layout) not working

北城余情 提交于 2021-02-18 18:54:56
问题 I have a problem with MVC4 CSS. i m including a CSS file named registration.css in an another view page named "registerUser.cshtml". This page is like a content page in mvc4 razor. but problem is that CSS is not working. How can i resolve this. I have also included in BundleConfig.cs as bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/registration.css")); But it is also not working. Help me. 回答1: Use @Styles.Render("~/Content/css") instead of @Styles.Render("~/Content

My app quits serving static files after the Windows April Update

这一生的挚爱 提交于 2021-02-18 18:43:06
问题 I have an app where the Content folder is filled by another process that builds a frontend app, and the Visual Studio project itself doesn't know what's in the folder. I set up the web.config with a standard <staticContent> node and <modules runAllManagedModulesForAllRequests="true"> . I have my RouteConfig set up with routes.IgnoreRoute("content/*"); The app typically runs with IIS Express, but I have also run it with IIS proper. This has all worked fine to load js, css, and other static

My app quits serving static files after the Windows April Update

大兔子大兔子 提交于 2021-02-18 18:42:15
问题 I have an app where the Content folder is filled by another process that builds a frontend app, and the Visual Studio project itself doesn't know what's in the folder. I set up the web.config with a standard <staticContent> node and <modules runAllManagedModulesForAllRequests="true"> . I have my RouteConfig set up with routes.IgnoreRoute("content/*"); The app typically runs with IIS Express, but I have also run it with IIS proper. This has all worked fine to load js, css, and other static

Dependency injection with unity in a class library project

笑着哭i 提交于 2021-02-18 17:35:12
问题 I am new with the dependency injection pattern. I'm a little confused about few things. Scenario: I have a class library project called 'MailCore'. This project has interfaces and classes that perform all email sending stuff. I have an MVC project called 'The site'. It uses the 'MailCore' project to send email. I have Unity in this project and the UnityContainer is registered and things are working fine. I also have another class library library project called 'SiteRepo'. Sometimes, to

Is it possible for a lambda function to contain Razor syntax and be executed in a View?

不羁岁月 提交于 2021-02-18 12:32:05
问题 Is it possible to define the contents of a lambda expression (delegate, Action, Func<>) with Razor syntax, so that when this model method is executed in the view, it will insert that Razor content? The intended purpose of this is for our developers to be able to define their own custom content to be inserted at a particular point in the CustomControl's view. The following is stripped-down example code that mimics my current layout. The particular parts of focus are the RenderSideContent

ASP.NET MVC - handling multiple objects in one form

自作多情 提交于 2021-02-18 12:30:06
问题 I have a scenario I'm stuck on - I have a domain object that has a collection of objects attached to it. Something like this: public class Person { public string Name { get; set; } public IList<PhoneNumber> PhoneNumbers {get; set; } public IList<Address> Addresses { get; set; } } The UI the client wants has a single input form for adding and editing. A user could enter 0 to many phones/addresses for each person. How do I handle posting the collection of values back to the controller? I can

Should controller lifestyle always be transient in Windsor configuration for ASP.NET MVC?

感情迁移 提交于 2021-02-18 12:22:31
问题 I ran into a problem where I had an Html.DropDownList in my view that would postback the selected value the first time I submitted the form, but each subsequent postback would only post data from the initial postback. So I added lifestyle="transient" to the component element where I had configured my controller for castle windsor, which fixed the problem, but of course made postbacks take longer since a new controller was being instantiated per request. Given the information above, what