@Aiti
2019-12-06T06:07:32.000000Z
字数 9084
阅读 374
未分类
在部署网站到服务器的时候,发现本地访问网站没问题,但是局域网其他机器无法访问,或者在把相应端口映射后,外网也无法访问初步解决方案——防火墙规则
1、打开【控制面板】,选择【WINDOWS 防火墙】,进入
2、在防火墙界面,选择左侧边栏的【高级设置】
3、在弹出的高级安全Windows防火墙界面中,选择左侧边栏的【入站规则】,然后在右侧边栏选择【新建规则】
4、在弹出的窗口中完成如下操作:
选择【端口】,下一步;
选择【TCP】以及【特定本地端口】,填入要开放的端口号(或开放所有端口,可以以逗号分隔多个端口),下一步;
【允许连接】,下一步;
网络类型全部勾选,下一步;
【名称】中填入自定义名称,如:IIS 【完成】。
using system.web
编码:
HttpUtility.UrlEncode(url)
解码:
HttpUtility.UrlDecode(url)
MD5:
1、不可逆性。
2、任意长度的明文字符串,加密后得到的密文字符串是长度固定的。
在加密用户的密码时,考虑到密码可能一样,需要用盐值来解决这个问题,就是给每个用户生成一个随机的盐值,在作保存和校验时,需要把用户的Salt值加入到密码原文中再作MD5运算,这样就可以使得相同的密码生成不同的编码.
//引用using System.Security.Cryptography;using System.Text;byte[] result = Encoding.Default.GetBytes(this.tbPass.Text.Trim()); //tbPass为输入密码的文本框MD5 md5 = new MD5CryptoServiceProvider();byte[] output = md5.ComputeHash(result);this.tbMd5pass.Text = BitConverter.ToString(output).Replace("-",""); //tbMd5pass为输出加密文本的文本框
//Bim999在这里就是固定盐值,固定盐值就不需要存入数据库
this.tbMd5pass.Text = = BitConverter.ToString(new MD5CryptoServiceProvider().ComputeHash(Encoding.Default.GetBytes("Bim999" + value.ToString()))).Replace("-", "");
Base64:
1、可逆性。
2、可以将图片等二进制文件转换为文本文件,方便使用HTTP协议等。
3、可以把非ASCII字符的数据转换成ASCII字符,避免不可见字符.
/// Base64加密,Encoding.UTF8采用utf8编码方式加密
using system.web
加密:
Base64Encode(Encoding.UTF8, str);
解密:
Base64Decode(Encoding.UTF8, str);
可以封装成一个Base64的帮助类;可以根据加密与解密的类型
class Base64Helper{/// <summary>/// Base64加密,采用utf8编码方式加密/// </summary>/// <param name="source">待加密的明文</param>/// <returns>加密后的字符串</returns>public static string Base64Encode(string source){return Base64Encode(Encoding.UTF8, source);}/// <summary>/// Base64加密/// </summary>/// <param name="encodeType">加密采用的编码方式</param>/// <param name="source">待加密的明文</param>/// <returns></returns>public static string Base64Encode(Encoding encodeType, string source){string encode = string.Empty;byte[] bytes = encodeType.GetBytes(source);try{encode = Convert.ToBase64String(bytes);}catch{encode = source;}return encode;}/// <summary>/// Base64解密,采用utf8编码方式解密/// </summary>/// <param name="result">待解密的密文</param>/// <returns>解密后的字符串</returns>public static string Base64Decode(string result){return Base64Decode(Encoding.UTF8, result);}/// <summary>/// Base64解密/// </summary>/// <param name="encodeType">解密采用的编码方式,注意和加密时采用的方式一致</param>/// <param name="result">待解密的密文</param>/// <returns>解密后的字符串</returns>public static string Base64Decode(Encoding encodeType, string result){string decode = string.Empty;byte[] bytes = Convert.FromBase64String(result);try{decode = encodeType.GetString(bytes);}catch{decode = result;}return decode;}}
首页ping一下远程地址(api.bim999.net),看看对应的IP是不是目标IP地址(192.168.1.143);
如果不是需要重新定向,修改Host的。
修改路径:C:\Windows\System32\drivers\etc
增加一条语句:
192.168.1.143 api.bim999.net
class NameValue {
public string Name { get; set; }
public JObject Value { get; set; }
}
var processArray = JsonConvert.DeserializeObject>(ParameterValue);
var subiteArray = JsonConvert.DeserializeObject>(Parent.ParameterValue);
var addnamevalue = new List();
foreach (var item in processArray)
{
var tt = subiteArray.Where(o => o.Name == item.Name);
if (tt.Count() > 0)
tt.FirstOrDefault().Value = item.Value;
else
{
addnamevalue.Add(item);
}
}
subiteArray.AddRange(addnamevalue);
//序列化保存到Parent中去
Parent.ParameterValue = JsonConvert.SerializeObject(subiteArray);
列如:需要调用这个函数:
private object ParentEquals<T>(object xpo,int Pid) where T: XPObject{if (Pid < 0)xpo = (xpo as IQueryable<IParentNested<T>>).Where(o => o.Parent==null);elsexpo = (xpo as IQueryable<IParentNested<T>>).Where(o => o.Parent.Oid == Pid);return xpo;}获取到的变量进行这样操作:public List<vDictBaseMini> SearchMini(vSearchModel sm){var xpo = GetDict(sm.SearchOption["DictType"],out Type t);if (sm.SearchOption.Keys.Contains("Parent") && !string.IsNullOrWhiteSpace(sm.SearchOption["Parent"])){MethodInfo mi = this.GetType().GetMethod("ParentEquals", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly).MakeGenericMethod(t);xpo = mi.Invoke(this, new object[] {xpo, Convert.ToInt32(sm.SearchOption["Parent"]) });}if (sm.SearchOption.Keys.Contains("Code") && !string.IsNullOrWhiteSpace(sm.SearchOption["Code"]))xpo = (xpo as IQueryable<DictBaseBase>).Where(o=>o.Code== sm.SearchOption["Code"]);return Mapper.Map<List<vDictBaseMini>>(xpo);}
**还有一种方式:return Mapper.Map<List<vDictBase>>(GetDict(DictType, out Type t))相当于return Mapper.Map<List<vDictBaseMini>>(xpo)**public List<vDictBase> Get(string DictType){return Mapper.Map<List<vDictBase>>(GetDict(DictType, out Type t));}private Object GetDict(string DictType,out Type XpoType){XpoType = null;Type t = null;foreach (var assembly in new AppDomainTypeFinder().GetAssemblies()){t = assembly.GetType(DictType);if (t != null)break;}if (t != null){Type QueryType = typeof(XPQuery<>).MakeGenericType(t);MethodInfo mi = typeof(ApiControllerBase).GetMethod("ScopeBeInclude").MakeGenericMethod(t);var list = mi.Invoke(this, new object[]{ Activator.CreateInstance(QueryType, session) });XpoType = t;return list;}return null;}
应用之后:v变量;var o = XpoHelper.ViewModelToXpo<NVRServer>(v, session,null);o.Save();对于“NVRServer”类型不确认的,通过接收参数来确认的解决:通过Url接收参数:var DictType = RequestHelper.Get("DictType");Type t = null;foreach (var assembly in new AppDomainTypeFinder().GetAssemblies()){t = assembly.GetType(DictType);if (t != null)break;}MethodInfo mi = typeof(XpoHelper).GetMethod("ViewModelToXpo").MakeGenericMethod(t);var o = (mi.Invoke(this, new object[] { v, session,null })) as XPBaseObject;o.Save();
public IHttpActionResult Delete(int id,string DictType){Type t = null;foreach (var assembly in new AppDomainTypeFinder().GetAssemblies()){t = assembly.GetType(DictType);if (t != null)break;}MethodInfo mi = this.GetType().GetMethod("GetObject").MakeGenericMethod(t);var o = (mi.Invoke(this, new object[] {id})) as XPBaseObject;Log.Warn(new XpoLog(XpoAppender.Session) { Action = "删除", Object = o, Message = "删除成功" });o.Delete();return Ok("删除成功。");}/// <summary>////// </summary>/// <typeparam name="T"></typeparam>/// <param name="id"></param>/// <returns></returns>public T GetObject<T>(int id){return session.GetObjectByKey<T>(id);}
/// <summary>/// 移除数组中重复数据/// </summary>/// <param name="array">需要除重的数组</param>/// <returns>不重复数组</returns>public static string[] DelRepeatData(string[] array){return array.GroupBy(p => p).Select(p => p.Key).ToArray();}
List<int> ages = new List<int> { 21, 46, 46, 55, 17, 21, 55, 55 };List<string> names = new List<string> { "wang", "li", "zhang", "li", "wang", "chen", "he", "wang" };IEnumerable<int> distinctAges = ages.Distinct();Console.WriteLine("Distinct ages:");foreach (int age in distinctAges){Console.WriteLine(age);}var distinctNames = names.Distinct();Console.WriteLine("\nDistinct names:");foreach (string name in distinctNames){Console.WriteLine(name);}
在这段代码中,是最简单的Distinct()方法的使用。使用了集合接口IEnumerable,以及隐式类型var,至于这两种用法有什么区别,没有研究出来。
但是如果象下面这样的代码,是错误的!
[csharp] view plain copyList<int> disAge = ages.Distinct();
正确的方法应该是:
[csharp] view plain copyList<int> ages = new List<int> { 21, 46, 46, 55, 17, 21, 55, 55 };List<int> disAge = ages.Distinct().ToList();foreach (int a in disAge)Console.WriteLine(a);
也就是说Distinct()方法的返回集合类型是一个接口,不是具体的集合,所以需要用一个ToList()。
jQuery(function ($) {$(function () {$(".btn-group").each(function () {if (HF.Get($(this).data("group"))) {$(this).find(".btn[data-criteria='" + HF.Get($(this).data("group")) + "']").addClass("focus");} else {$(this).find(".btn:first").addClass("focus");$(this).find(".btn:first").addClass("BusinessBlue");}});});$(".btn-group .btn").click(function () {//alert($(this).data("criteria"));$(this).parent().find(".btn").removeClass("focus");$(this).parent().find(".btn").removeClass("BusinessBlue");$(this).parent().find(".btn").removeClass("ElegantBlack");$(this).parent().find(".btn").removeClass("FreshBlue");$(this).addClass("focus");$(this).addClass($(this).data("criteria"));HF.Set($(this).parent().data("group"), $(this).data("criteria"));});});
<dx:ASPxHiddenField ID="HF" runat="server" ClientIDMode="Static" ></dx:ASPxHiddenField><div class="divstyle"><span class="ml20">界面风格</span><div class="btn-group" data-group="status"><button type="button" class="btn btn-default" data-criteria="BusinessBlue">商务蓝</button><button type="button" class="btn btn-default" data-criteria="ElegantBlack">优雅黑</button><button type="button" class="btn btn-default" data-criteria="FreshBlue"">清新蓝</button></div></div>
if (!HF.Contains("status")){HF.Set("status", "BusinessBlue");}if (HF.Get("status").ToString() == "ElegantBlack"){}else if(HF.Get("status").ToString() == "FreshBlue"){}
问题:未在本地计算机上注册Microsoft.ACE.OLEDB.12.0提供程序
// 解决访问Excel数据源时出现 未在本地计算机上注册Microsoft.ACE.OLEDB.12.0提供程序
// 1、确保安装了Microsoft.ACE.OLEDB.12.0驱动
// http://download.microsoft.com/download/7/0/3/703ffbcb-dc0c-4e19-b0da-1463960fdcdb/AccessDatabaseEngine.exe
// 2、在vs中右击项目--》属性--》生成 下的 目标平台 改为x86
// 如果以上两个方法还是不行的话,用第三个方法
// 3、在对应的 IIS 应用程序池中,“设置应用程序池默认属性”右击/“高级设置”/"启用32位应用程序",设置为 true。