资源简介

在csdn上你可以搜到 书店实例.doc 那个资源。这个项目就是按照这个文档写出来的,但是那个文档在认证授权上有缺陷,而且购物车是放在后端数据库里面的,没有验证码部分。所以在本案例中我加入了 验证码,分页,认证授权,以及ceditor等等技术,并把购物车放进了cookie中。基本上对于初级的web开发,这里面的技术都涉及到了一点,希望对初学者有用。www.shouji0512.com这个网站就是用这个案例中涉及到的所有技术做出来的,当然实际开发中需要考虑更多的因素,这里就不多说了。本案例是用vs10做的,基本上附加后都可以直接运行。希望本案例对你有帮助。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.Security;

namespace MvcBookStore
{
    // 注意: 有关启用 IIS6 或 IIS7 经典模式的说明,
    // 请访问 http://go.microsoft.com/?linkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
        }

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute(“{resource}.axd/{*pathInfo}“);

            routes.MapRoute(
                “booklist2“ // 路由名称
                “store-{id}-{page}-{order}.aspx“ // 带有参数的 URL
                new { controller = “Store“ action = “Browse“ } // 参数默认值
                );


            routes.MapRoute(
                “Store“ // 路由名称
                “StoreDetail-{id}.aspx“ // 带有参数的 URL
                new { controller = “Store“ action = “Details“ } // 参数默认值
                );

            routes.MapRoute(
                “Default“ // 路由名称
                “{controller}.aspx/{action}/{id}“ // 带有参数的 URL
                new { controller = “Home“ action = “Index“ id = UrlParameter.Optional } // 参数默认值
            );

        }

        protected void Application_Start()
        {
            Application[“mycxt“]=“book/“;

            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }

        protected void Application_AuthenticateRequest(object sender EventArgs e)
        {
            HttpApplication app = (HttpApplication)sender;
            HttpContext context = app.Context; //获取本次Http请求的HttpContext对象 
            bool b = context.Request.IsAuthenticated;

            if (context.Request.IsAuthenticated) //验证过的一般用户才能进行角色验证 
            {
                FormsIdentity Id = (FormsIdentity)context.User.Identity; //当前用户标识
                
                FormsAuthenticationTicket Ticket = Id.Ticket; //取得身份证票 
                string[] Roles = Ticket.UserData.Split(‘‘); //将角色数据转成字符串数组得到相关的角色信息 
                context.User = new System.Security.Principal.GenericPrincipal(Id Roles); //重新生成带有角色信息的用户
            }
        }


    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     783648  2011-12-09 18:23  MvcBookStore\MvcBookStore\bin\Entityframework.dll

     文件     834489  2011-12-09 18:23  MvcBookStore\MvcBookStore\bin\Entityframework.xml

     文件      44544  2012-01-23 13:39  MvcBookStore\MvcBookStore\bin\MvcBookStore.dll

     文件      67072  2012-01-23 13:39  MvcBookStore\MvcBookStore\bin\MvcBookStore.pdb

     文件      25088  2011-03-10 18:01  MvcBookStore\MvcBookStore\bin\MvcCaptchaExtensionMVC3.dll

     文件      42496  2011-03-10 18:01  MvcBookStore\MvcBookStore\bin\MvcCaptchaExtensionMVC3.pdb

     文件     370176  2011-09-23 20:24  MvcBookStore\MvcBookStore\bin\MySql.Data.dll

     文件     233984  2011-09-23 20:25  MvcBookStore\MvcBookStore\bin\MySql.Data.Entity.dll

     文件      92160  2011-09-23 20:25  MvcBookStore\MvcBookStore\bin\MySql.Web.dll

     文件        792  2009-08-20 15:14  MvcBookStore\MvcBookStore\ckeditor\.htaccess

     文件      20161  2009-08-20 15:14  MvcBookStore\MvcBookStore\ckeditor\CHANGES.html

     文件     265360  2009-08-20 15:14  MvcBookStore\MvcBookStore\ckeditor\ckeditor.js

     文件       6857  2009-08-20 15:14  MvcBookStore\MvcBookStore\ckeditor\ckeditor.pack

     文件       6445  2009-08-20 15:14  MvcBookStore\MvcBookStore\ckeditor\ckeditor_basic.js

     文件       1530  2009-08-20 15:14  MvcBookStore\MvcBookStore\ckeditor\ckeditor_basic_source.js

     文件       1608  2009-08-20 15:14  MvcBookStore\MvcBookStore\ckeditor\ckeditor_source.js

     文件        331  2009-08-20 15:14  MvcBookStore\MvcBookStore\ckeditor\config.js

     文件        674  2009-08-20 15:14  MvcBookStore\MvcBookStore\ckeditor\contents.css

     文件         43  2009-08-20 15:14  MvcBookStore\MvcBookStore\ckeditor\images\spacer.gif

     文件       2859  2009-08-20 15:14  MvcBookStore\MvcBookStore\ckeditor\INSTALL.html

     文件      13110  2009-08-20 15:14  MvcBookStore\MvcBookStore\ckeditor\lang\en.js

     文件      12932  2009-08-20 15:14  MvcBookStore\MvcBookStore\ckeditor\lang\zh-cn.js

     文件      12977  2009-08-20 15:14  MvcBookStore\MvcBookStore\ckeditor\lang\zh.js

     文件      71136  2009-08-20 15:14  MvcBookStore\MvcBookStore\ckeditor\LICENSE.html

     文件       1378  2009-08-20 15:14  MvcBookStore\MvcBookStore\ckeditor\plugins\about\dialogs\about.js

     文件       2759  2009-08-20 15:14  MvcBookStore\MvcBookStore\ckeditor\plugins\about\dialogs\logo_ckeditor.png

     文件        441  2009-08-20 15:14  MvcBookStore\MvcBookStore\ckeditor\plugins\about\plugin.js

     文件       1145  2009-08-20 15:14  MvcBookStore\MvcBookStore\ckeditor\plugins\basicstyles\plugin.js

     文件       3703  2009-08-20 15:14  MvcBookStore\MvcBookStore\ckeditor\plugins\blockquote\plugin.js

     文件       2995  2009-08-20 15:14  MvcBookStore\MvcBookStore\ckeditor\plugins\button\plugin.js

............此处省略429个文件信息

评论

共有 条评论