转:ASP.NET MVC 3 and App_Code folder
问题:
In ASP.NET Webform, App_Code is standardfolder to putting code and using it at run-time.But I think this folder is kind of different in ASP.NET MVC, my question is:
where should I put my code ( Extension methods , Helpers , ... ) in ASP.NET MVC. When I store code in App_Code folder, I can't use theme in controller but they work fine in views.
About Entity Framework, the same question, where should I put edmx and tt files. I'm not using Code-First
Update:
After some search, finally I created a new Class Library project in my solution, code is available in allcontrollers and views. I still don't know why the code in App_Code is not available in controller
回答 :
App_Code is necessary in Web Site projects because it has a special meaning. It means "Don't serve these files to a web browser". In ASP.NET MVC, files are not directly served to the browser in most cases, so App_Code is not necessary. You can place code files whereever you want, in any folder you want.
Using a stand-alone library is also a fine solution.
转:ASP.NET MVC 3 and App_Code folder的更多相关文章
- ASP.NET MVC项目中App_Code目录在程序应用
学习ASP.NET MVC,如果你是开发ASP.NET MVC项目的,也许你去为项目添加前ASP.NET项目的APP_Code目录,在这里创建与添加的Class类,也许你无法在MVC项目所引用. 那这 ...
- Mixing ASP.NET Webforms and ASP.NET MVC
https://www.packtpub.com/books/content/mixing-aspnet-webforms-and-aspnet-mvc *********************** ...
- 创建可复用的自定义 ASP.NET MVC Helpers
通常,在ASP.NET MVC项目中App_Code目录下新建.cshtml编写类似下方的代码就能创建自定义的MVC Helper了, 假设文件名为StrHelper.cshtml,那么在别的视图中的 ...
- Asp.Net MVC App_Code无法识别
Asp.Net MVC需要写公共类的时候 右击添加 App_Code 文件夹,新建类—>右击类—>属性,生成操作 —>选择 —>编译 Asp.Net MVC项目本身是个应用程序 ...
- 【Pro ASP.NET MVC 3 Framework】.学习笔记.11.ASP.NET MVC3的细节:概览MVC项目
书Adam The Definitive Guide to HTML5 Adam Applied ASP.NET 4 in Context and Pro ASP.NET 4 到此为止,我们已经学了为 ...
- ASP.NET MVC 3 and the @helper syntax within Razor
Friday, May 13, 2011 ASP.NET MVC 3 supports a new view-engine option called “Razor” (in addition to ...
- 翻译:使用 ASP.NET MVC 4, EF, Knockoutjs and Bootstrap 设计和开发站点 - 3
原文地址:http://ddmvc4.codeplex.com/ 原文名称:Design and Develop a website using ASP.NET MVC 4, EF, Knockout ...
- 七天学会ASP.NET MVC (六)——线程问题、异常处理、自定义URL
本节又带了一些常用的,却很难理解的问题,本节从文件上传功能的实现引出了线程使用,介绍了线程饥饿的解决方法,异常处理方法,了解RouteTable自定义路径 . 系列文章 七天学会ASP.NET MVC ...
- 4、ASP.NET MVC入门到精通——NHibernate构建一个ASP.NET MVC应用程序
下周就去办理离职手续了,之前没有使用过NHibernate,只知道NHibernate是一种ORM框架,但是听说新公司是使用NHibernate在做项目,所以,我就网上找资料学习一下NHibernat ...
随机推荐
- APP上架详细流程-2016最新
注:文章为博主原创,转载请注明出处 由于新项目要上架,并且发现了与以往不同的地方特此总结 原料: 0.MAC一台 1.可用的开发者账号 2.AppID 3.发布证书 4.描述性文件 上架步骤: 一.在 ...
- Centos 7 yum 安装Apache
1.首先查看是否已经安装 rpm -qa httpd 2.如果没有 yum install httpd -y rpm -ql httpd 查看 3 ...
- 解决Please ensure that adb is correctly located at 'D:\java\sdk\platform-tools\adb.exe' and can be executed.
遇到问题描述: 运行android程序控制台输出 [2012-07-18 16:18:26 - ] The connection to adb is down, and a severe error ...
- windows8 认识及使用
windows8的一次技术分享. 利用国庆宅家的几天,在跑不动XP的老笔记本上装了win8,嘿,跑的溜溜的,一高兴做个ppt给公司的同事们介绍介绍,随意之作,勿较真抬杠,呵呵. 文件地址:http:/ ...
- unity3d 中加入�视频
加入�音频 视频 using UnityEngine; using System.Collections; public class play_video : MonoBehaviour { publ ...
- forward_list例子
9.28 编写函数,接受一个forward_list<string>和两个string共三个参数.函数应在链表中查找第一个string,并将第二个string插入到紧接着第一个string ...
- 信号之abort函数
abort函数的功能是使异常程序终止. #include <stdlib.h> void abort(void); 此函数不返回 此函数将SIGABRT信号发送给调用进程(进程不应忽略此信 ...
- mysqldump 的一些使用参数
备份数据库#mysqldump 数据库名 >数据库备份名 #mysqldump -A -u用户名 -p密码 数据库名>数据库备份名 #mysqldump -d -A --add-drop- ...
- java_可变参数构造器 Bulder模式
package com.test1.www; class NutritionFacts { //必须 private int servingSize; private int servings; // ...
- Android(java)学习笔记127:Android Studio新建工程中的build.gradle、settings.gradle
随着信息化的快速发展,IT项目变得越来越复杂,通常都是由多个子系统共同协作完成.对于这种多系统.多项目的情况,很多构建工具都已经提供了不错的支持,像maven.ant.Gradle除了借鉴了ant或者 ...