2013-0725

在asp.net mvc的强类型视图(strongly typed view)使用下拉列表,在Controller中设定的选择项在View上选中失效


下面是我的代码:

public ActionResult Create(int id=0,int parentid=0)
{
    var productCategory=db.ProductCategorys.Where(pc => pc.ParentID == parentid).ToList();
    productCategory.Insert(0,new ProductCategoryModel() { Name = "顶级分 阅读全文>>
                
标签: ASP.NET MVC SelectList selected 阅读:11108
2013-0724

mvc使用Area分区开发后,存在在不同Area间跳转,需要为每个区间添加Area规则,如下:

public class CompanyAreaRegistration : AreaRegistration
{
    public override string AreaName
    {
        get
        {
            return "Company";
        }
    }
    public override void RegisterArea(AreaRegistrationContext context)
    {
        context 阅读全文>>
                
标签: ASP.NET MVC RedirectToAction Area 阅读:20207
2013-0605

通过GPS或者北斗定位坐标和中国国内地图坐标有偏移,纠正方法如下:11

/// <summary>
        /// 百度地图纠正偏移
        /// </summary>
        /// <param name="requestModel"></param>
        /// <returns></returns>
        private RequestModel GetRealyLanANdLat(RequestModel requestModel)
        {
            string 阅读全文>>
                
标签: 定位偏移 GPS 北斗 定位偏移纠正 Base64 阅读:10907
2013-0529
[Display(Name="发布时间:")]
[DataType(DataType.Date)]
public DateTime PubTime { get; set; }


修改如下:

[Display(Name="发布时间:")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
public DateTime PubTime { get; set; }


说明 Html5的 阅读全文>>

标签: MVC4 DataType.Date EditorFor Html5 type="date" input 阅读:18746
2013-0510

在SEO搜索优化中都有要求提交SiteMap的,例如google,百度都有这个功能。具体意义不再本文讨论中。


几个重要的问题

  1. 生成文章类动态sitemap.xml文件

  2. 生成sitemapindex.xml文件

  3. 何时调整以上两个文件做到时效性


第一步生成以上两个xml文件,以下代码放于HomeCo 阅读全文>>

标签: MVC SiteMap SiteMapIndex Xml 阅读:16331
2013-0510

网站要对外提供资源订阅,自然少不了Rss支持,Rss就是遵循Rss格式的xml文档,网站能自动生成这个自然能方便很多。

示例:http://www.yn-s.com/Home/Rss


腾讯也提供邮箱订阅功能,前提是你网站要支持rss。


以下是mvc实现此功能代码:

public ActionResult Rss()
        {
                var articles =db.Articles.OrderByDescending 阅读全文>>
                
标签: MVC RSS 资源订阅 阅读:13917