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. 状态压缩dp初学__$Corn Fields$

    明天计划上是要刷状压,但是作为现在还不会状压的\(ruoruo\)来说是一件非常苦逼的事情,所以提前学了一下状压\(dp\). 鸣谢\(hmq\ juju\)的友情帮助 状态压缩动态规划 本博文的大体 ...

  2. 知方可补不足~powerDesign为模型添加注释(让生成的SQL有注释)

    事实上powerDesign本身就有这个功能,不需要我们修改它的生成器了,这种方法够简单! 一 打开表模型,选择column标签

  3. MySQL修改最大连接数,没有my.ini文件,只有my-default,这怎么改呀?

    # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/en/server-co ...

  4. 在 Ubuntu 18.04 LTS 无头服务器上安装 Oracle VirtualBox

    作者: Sk 译者: LCTT qhwdw | 2018-10-12 01:59 本教程将指导你在 Ubuntu 18.04 LTS 无头服务器上,一步一步地安装 Oracle VirtualBox. ...

  5. 联想服务器thinkserver TS550 Raid5制作及winserver2012R2 安装过来

    一. 联想服务器thinkserver TS550 Raid5制作 1.开机后按ctrl+i  进入raid配置模式 2.选择“1”配置所需Raid模式(这次配的是raid5) 3.按提示确认后退出 ...

  6. d3的一些总结

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

  7. [NOIP2014普及组]子矩阵

    题目:洛谷P2258.Vijos P1914.codevs 3904. 题目大意:给你一个矩阵,要你找一个r行c列的子矩阵,求最小分值(子矩阵和分值的定义见原题). 解题思路:n和m比较小,考虑暴力. ...

  8. Project Euler:Problem 58 Spiral primes

    Starting with 1 and spiralling anticlockwise in the following way, a square spiral with side length ...

  9. iPad popView封装

    仿照UITableView的UITableViewDataSource 协义 1.代理.让代理帮我们类完毕一些方法 2.完毕当前类不能完毕的事情还有传值等功能 实现方法 // 1. 声明一个协议 // ...

  10. ios svn repository

    xcode默认自带Git和svn,首先讲下xcode4.6.3下配置svn: 1.检測你的mac中是否安装了svn: (1) 打开终端,输入 svn --version 假设出现下图信息,则说明已经安 ...