using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc; namespace mvcDemo.Controllers
{
public class StoreController : Controller
{
// GET: Store
public string Index()
{
return "Hello from Store.Index()";
} // GET: Store
public string Browse()
{
return "Hello from Store.Browse()";
} // GET: Store
public string Details()
{
return "Hello from Store.Details()";
}
}
}

在浏览器地址后面输入"/Store/Index"

就能看到返回的字符串数据了。

传递参数,

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc; namespace mvcDemo.Controllers
{
public class StoreController : Controller
{
// GET: Store
public string Index()
{
return "Hello from Store.Index()";
} // GET: Store
public string Browse(string genre)
{
string message = HttpUtility.HtmlEncode("Genre =" +genre);
return message;
} // GET: Store
public string Details()
{
return "Hello from Store.Details()";
}
}
}

新的传递方式

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc; namespace mvcDemo.Controllers
{
public class StoreController : Controller
{
// GET: Store
public string Index()
{
return "Hello from Store.Index()";
} // GET: Store
public string Browse(string genre)
{
string message = HttpUtility.HtmlEncode("Genre =" +genre);
return message;
} // GET: Store
public string Details(int id)
{
string message = "Store.Details,ID = " + id;
return message;
}
}
}

.Net MVC小尝试的更多相关文章

  1. MVC小系列(八)【改变Areas的FindView顺序】

    MVC小系列(八)[改变Areas的FindView顺序] 一般项目比较大的话,会根据模块建立Areas,这样结构清晰,也有利于路由的部署, 1 Areas下有自己的_LayOut模板,而如果希望所有 ...

  2. MVC小系列(七)【分部视图中的POST】

    MVC小系列(七)[分部视图中的POST] 在PartialView中进行表单提交的作用:1 这个表单不止一个地方用到,2 可能涉及到异步的提交问题 这两种情况都可能需要把表单建立在分部视图上, 使用 ...

  3. MVC 小案例 -- 信息管理

    前几次更新博客都是每次周日晚上到周一,这次是周一晚上开始写,肯定也是有原因的!那就是我的 Tomact 忽然报错,无法启动,错误信息如下!同时我的 win10 也崩了,重启之后连 WIFI 的标志也不 ...

  4. MVC 小常识

    什么是MVC (模型 视图 控制器)? MVC是一个架构模式,它分离了表现与交互.它被分为三个核心部件:模型.视图.控制器.下面是每一个部件的分工: 视图是用户看到并与之交互的界面. 模型表示业务数据 ...

  5. MVC小系列(二十二)【MVC的Session超时,导致的跳转问题】

    由于mvc内部跳转机制的问题,它只在当前的action所渲染的view上进行跳转,如果希望在当前页面跳,需要将mvc方法改为js方法: filterContext.Result = new Redir ...

  6. MVC小系列(十八)【给checkbox和radiobutton添加集合的重载】

    mvc对DropDownListFor的重载很多,但对checkbox和radiobutton没有对集合的重载 所以该讲主要针对集合的扩展: #region 复选框扩展 /// <summary ...

  7. MVC小系列(十七)【自定义验证规则给下拉框】

    因为下拉框不支持验证,所以写一个attribute特性,让它继承ValidationAttributemvc的特性验证,很直接,无论是数据安全特性上还是页面表现上都不错,它的运行机制: 前台表单验证规 ...

  8. MVC小系列(十六)【在控制器级别或具体Action级别上动态设定模板页(Layout)】

    方法就是使用:ActionFilterAttribute它的几个方法:OnActionExecuted,OnActionExecuting,OnResultExecuted和OnResultExecu ...

  9. MVC小系列(十五)【MVC+ZTree实现对树的CURD及拖拽操作】

    根据上一讲的可以加载一棵大树,这讲讲下如果操作这颗大树 <link href="../../Scripts/JQuery-zTree/css/zTreeStyle/zTreeStyle ...

随机推荐

  1. <Sicily>Inversion Number(线段树求逆序数)

    一.题目描述 There is a permutation P with n integers from 1 to n. You have to calculate its inversion num ...

  2. c# 枚举enum

    1 定义枚举 enum Days { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday }; 默认情况下,枚举中的每个元素的 ...

  3. T_SQL 日期函数

    日期函数基数表达式的日期和时间或者是从时间间隔中返回值. GETDATE(),返回当前系统的日期和时间.例: SELECT GETDATE();  结果为:2010-05-18 15:53:08.92 ...

  4. d3的一些总结

    核心操作:https://blog.csdn.net/kriszhang/article/details/70174410 Update.Enter.Exit 简练详细说明:http://www.cn ...

  5. NodeJS代码调试

    1.在Chrome打开chrome://flags/#enable-devtools-experiments 2.激活Developer Tools experiments 3.重启Chrome 4. ...

  6. unity 5.6.1 Oculus手柄输入问题

    unity文档中提到 轴的 ID 是5和6,但是测试后发现,ID是6和7,很坑 void Update () { if (Input.GetKeyDown(KeyCode.JoystickButton ...

  7. 【SRM 717 div2 B】LexmaxReplace

    Problem Statement Alice has a string s of lowercase letters. The string is written on a wall. Alice ...

  8. 洛谷——P1019 单词接龙(NOIP2000 T3)

    https://www.luogu.org/problem/show?pid=1019#sub 题目描述 单词接龙是一个与我们经常玩的成语接龙相类似的游戏,现在我们已知一组单词,且给定一个开头的字母, ...

  9. 開始EEPlat之旅

    怎样開始EEPlat之旅 EEPlat分为社区版和商业版:功能上分为企业版和PaaS版.下面为社区企业版的開始之旅. 第一步:安装project,有两种:war包和代码project.(眼下googl ...

  10. Windows安装两个mysql数据库步骤

    因为新旧项目数据库版本号差距太大.编码格式不同.引擎也不同,所以仅仅好装两个数据库. 本次安装两个mysql数据库.版本号各自是4.0.18,5.5.36.都是可运行文件直接安装. 本机上之前已经安装 ...