zoukankan      html  css  js  c++  java
  • .Net MVC小尝试

    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;
            }
        }
    }
    
  • 相关阅读:
    【C&数据结构】---关于链表结构的前序插入和后序插入
    【LC_Overview1_5】---学会总结回顾
    【LC_Lesson5】---求最长的公共前缀
    xorm -sum 系列方法实例
    xorm -Alias,Asc,Desc方法实例
    xorm -Find方法实例
    xorm -Exist方法实例
    xorm -Get方法实例
    xorm-创建时间created
    xorm插入数据实例
  • 原文地址:https://www.cnblogs.com/jiqing9006/p/6874716.html
Copyright © 2011-2022 走看看