Wednesday, September 21, 2016

Msbuild - Publish Example Console


msbuild SiteName.sln /t:Rebuild /p:outdir="c:\\tmp\\" /p:Configuration=Acctest /p:Platform="Any CPU"


Add 7z support in cmd

Permanent
setx /M PATH="%PATH%;C:\Program Files\7-Zip\

Locally non permanent
set PATH=%PATH%;C:\Program Files\7-Zip\
echo %PATH%
7z

Tuesday, September 20, 2016

Expose - Local Website publically fast and simple


Download the open source tool:

ngrok.com

Install

Then bind the site with the following command.
Logon to ngrok and bind your config.



 ngrok http 80 --host-header="somesite.no:80"

Dokumentation:
https://ngrok.com/docs
 
 
Example with a local https site:
ngrok http https://mylocalsite.se:443 --host-header="mylocalsite.se:443"                   

Linux - Bash - Pointing to currentdirectory when using command


Current directory: . Example : mv file.txt .

Home directory: ~

If we want to print this directory we use the pwd (print working directory)


For instance if we are in /mydir

and we want to 7zip this dir then 
7z a Nameofzip ./

./ will then point to /mydir



R  W   X
4 +2 +1  = 7

chmod -o+w file/dir

(U+G+O) = User Group Other

Octal notation

You may read or set permissions using a 3 digit octal number. The digits represent the owner, group, and other permissions, from left to right. Each digit may be 0 through 7 representing the different combinations of read, write, and execute.
To compute what each digit means, use this formula.
read/r = 4
write/w = 2
execute/x = 1

For each permission you want to grant, sum their corresponding values.


Toogle Jobs

ctrl + z - Cancel current job/task.
jobs  - list current running jobs/task.
fg #number select current job/task.


Kill process:

list : ps -aux.
ps -aux | grep something.
kill -STOP or -TERM or -KILL


Monday, September 19, 2016

MVC - Create Simple Custom MVC View Helper

 In View  
  @Html.OrderedListHelper(list)
  
 In Class  
  public static MvcHtmlString OrderedListHelper(this HtmlHelper html, List<string> data)  
     {  
       var ulbuilder = new TagBuilder("ul");  
       foreach (var item in data)  
       {  
        var libuilder = new TagBuilder("li");   
         libuilder.SetInnerText(item);  
         ulbuilder.InnerHtml += libuilder.ToString();  
       }  
       return new MvcHtmlString(ulbuilder.ToString());  
     }  

Thursday, September 15, 2016

Nice Visual studio Addons


Open Command Line


Node - Expose Webserver tunnel to Localhost

Install the NPM like this:

npm install -g iis-express-tunnel

Then Bind the local site:
iis-lt -p 80 --local-host localsite.com -o


You should recieve a adress to the site that is available from the net.

Sunday, September 4, 2016

MVC - Redirect All traffic to one controller

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

            routes.MapRoute(
                name: "Default",
                url: "{*url}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }


HttpContext.Request.Url
{http://redirecttoexternal.se/dinmamma/whatever/?d=1}
    AbsolutePath: "/dinmamma/whatever/"
    AbsoluteUri: "http://redirecttoexternal.se/dinmamma/whatever/?d=1"
    Authority: "redirecttoexternal.se"
    DnsSafeHost: "redirecttoexternal.se"
    Fragment: ""
    Host: "redirecttoexternal.se"
    HostNameType: Dns
    IdnHost: "redirecttoexternal.se"
    IsAbsoluteUri: true
    IsDefaultPort: true
    IsFile: false
    IsLoopback: false
    IsUnc: false
    LocalPath: "/dinmamma/whatever/"
    OriginalString: "http://redirecttoexternal.se:80/dinmamma/whatever/?d=1"
    PathAndQuery: "/dinmamma/whatever/?d=1"
    Port: 80
    Query: "?d=1"
    Scheme: "http"
    Segments: {string[3]}
    UserEscaped: false
    UserInfo: ""

Friday, September 2, 2016

IIS - Grant Default App Pool


It's called IIS APPPOOL\DefaultAppPool

CMD command
icacls c:\inetpub\wwwroot /grant "IIS APPPOOL\DefaultAppPool":(OI)(CI)(RX)

Of course to complicated things this users is sometimes called IIS_IUSRS

First of all: you don't have to change anything in your config file. It's OK. The problem is with windows file permissions.

This problems occurs because your application can not access and read web.config file.

Make the file accessible to IIS_IUSRS group. Just right click web.config and click properties, under security tab, add IIS_IUSRS.

So what is this IIS_IUSRS thing?

Your web site is like an exe file. Just like any exe file, it should be started by a user and it runs according to permissions assigned to that user.

When your site is started in IISApplication Pool of your web site is associated with a user (Network Services, Local System, Etc. ...) (and can be changed in IIS)

So when you say IIS_IUSRS, it means any user (Network Services, Local System, Etc. ...) that your site is running as.

And as @Seph mentioned in comment belowIf your computer is on a domain, remember that IIS_IUSRS group is a local group. Also make sure that when you're trying to find this user check the location it should be set to local computer and not a corporate domain.