วันพุธที่ 14 ธันวาคม พ.ศ. 2559

How to publish .Net Core ON IIS

Today I just try new Programming on .Net Core.
MVC Style and work fine on local Host  but when publish on IIS Server it can't run correctly.

First with 504 error then after few try error with 500 and finally I made it worked then follow below step.

This step will make you run it smoothly.

1. I use File System  to publish for manual upload by my FTP
2. In server IIS you must install .Net Core for Hosting and can download at https://aka.ms/dotnetcore_windowshosting_1_1_0
3. after install go to Command Prompt in server and type iisreset (I use GUI before but don't work)
4. Test Core by type dotnet to see if u can call dotnet service.
5. Add New Application Pool with .NET Framework version -> No Managed Code
6. Add Website by point to Your root app and application pool you create.
7. Your Website should work now.


วันอาทิตย์ที่ 31 พฤษภาคม พ.ศ. 2558

MVC Code First Command

enable-migrations

add-migration

update-database  

วันศุกร์ที่ 29 พฤษภาคม พ.ศ. 2558

Install Apache 2.4 and PHP 5.4 on Windows Server 2012 and support for CodeIgniter

Not simple not much but this is step for me to do this success.
1. Download and Extract Apache and PHP to root directory or what u want.
2. Config Apache and PHP

Yes 2 step and this job will done. here we go.
Step 1 Download 32 bit version (or 64 bit if u need but u need any library for 64 bit too. but php 5.4 has only 32bit ) for Apache and PHP
I use httpd-2.4.12-win32-VC11.zip from https://www.apachelounge.com/download/
this need VC++ 11.0 that u can find at https://support.microsoft.com/en-us/kb/2977003
make sure u use correct 32 bit or 64 bit version for me i use 32 bit in my Windows Server 2012 64bit
for PHP to use with apache we must use Thread Safe version I download php-5.4.41-Win32-VC9-x86.zip from here http://windows.php.net/download#php-5.4

Extract both files.

for Apache Copy Apache24 inside extract folder to root Drive (or whatever u want)
for PHP extract to c:/php54ts (or whatever u want)

finish step 1 here.

Step 2 Configuration
I will config PHP first
1. go to php folder and copy php.ini-production save as to php.ini or rename it (if u don't want any backup)
2. Edit list here

2.1  for this line make sure u create folder logs in php folder
error_log = "C:\php54ts\logs\php_error.log"

2.2 copy or uncomment this
extension_dir = "ext"

2.3 uncomment this extension
extension=php_mysql.dll
extension=php_mysqli.dll

2.4 time zone setting
date.timezone = "Asia/Bangkok"

this is done for PHP
3 go to Apache24 folder and edit httpd.conf in Apache24/conf folder
3.1 ServerRoot to your root folder.
3.2  Listen for your Port 
3.3 Uncomment this line for module rewrite
LoadModule rewrite_module modules/mod_rewrite.so
3.4 ServerName (for this line because i don't have domain name so i set 127.0.0.1:port for me
3.5 Change AllowOverride None to AllowOverride All for
for me line 226

     AllowOverride None
     Require all denied

And another line is 264 in


3.6 Line 277  for Index page
DirectoryIndex index.html index.php

3.7 and for last line add this (if u use folder php545ts like me)
LoadModule php5_module "c:/php54ts/php5apache2_4.dll"
AddHandler application/x-httpd-php .php

# configure the path to php.ini
PHPIniDir "C:/php54ts"

we end configuration Apache here.

4. Make Apache to service with Command.
4.1 add path for php and apache in system PATH
;c:\php54ts;c:\Apache24;c:\Apache24\bin
4.2 Install service by Command
c:\Apache24\bin\httpd -k install
(and can remove service with httpd -k unintall)

if u don't found any errors then anything will work fine.
go to service manager in Administrative tools and start Apache service

now we can test with basic PHP file info.
phpinfo()
?>

Hope this help.

วันอังคารที่ 2 กันยายน พ.ศ. 2557

๊Update ntext With replace Function

UPDATE [db_name].[dbo].[db_table]
SET [column_name]= CAST(replace(CAST(column_name as NVarchar(MAX)),'text_original','text_toreplace') AS NText) WHERE [column_condition]= [condition_value]

Best Free Software For Your Personal Computer

Create PDF

PDFCreator
http://www.pdfforge.org/pdfcreator

Notepad (Alternative)

Notepad++
http://notepad-plus-plus.org

Download Manager

Free Download Manager
http://www.freedownloadmanager.org

Image Viewer

XNView
http://www.xnview.com
IRFANVIEW
http://www.irfanview.com/

You can suggest more. but for now this is all I try and work well With my Windows 8.1, Widows 7 and Windows Server 2012.


Free tool for Web Developer

Fiddler2
http://www.fiddler2.com

W3C Validator
http://validator.w3.org/

http://xdebug.org/

http://home.snafu.de/tilman/xenulink.html

http://notepad-plus-plus.org/

https://addons.mozilla.org/en-US/firefox/addon/web-developer/

http://colorcop.net/

http://getfirebug.com/


Free use full Opensource for Bug Tracking and Blogger

I Like to use PHP and .Net so this my choice.
Bug Tracking

ASP.NET

BugNET
http://www.bugnetproject.com

BugTracker.NET
http://www.ifdefined.com/bugtrackernet.html

PHP

Mantis Bug Tracker
http://www.mantisbt.org

Blogger
BlogEngine.NET
http://www.dotnetblogengine.net

วันอาทิตย์ที่ 13 กรกฎาคม พ.ศ. 2557

MVC 5 AddOrUpdate

to use AddOrUpdate with entity command use this line on using (top of page)
using System.Data.Entity.Migrations;


if not  it will have only Add function for entities.

วันพฤหัสบดีที่ 26 มิถุนายน พ.ศ. 2557

Responsive web design

http://getbootstrap.com - this is default in MVC 5 in Visual Studio.Net
http://foundation.zurb.com - zurb has good job on this work for now this is version 5
http://www.getskeleton.com - never use this.
http://lessframework.com - never use this.

A circular reference was detected while serializing an object of type 'System.Data.Entity.DynamicProxies.xxx'

This happened when i need to use auto complete to get Object list by Entity.
Yep i support i use Lazy loading so
before call and return code must config for not Lazy loading like


db.Configuration.ProxyCreationEnabled = false;

วันพฤหัสบดีที่ 19 มิถุนายน พ.ศ. 2557

Cannot implicitly convert type 'System.Threading.Tasks.Task' to 'xxx.ApplicationUser'

This happened when I use Microsoft.AspNet.Identity in m WebForm Application with fucntion FindSync
this not will be problem if use this function with await in public async Task<ActionResult>

but for Web Form in "protected void" it will show error like this.

simply to convert task to object is enough then from
ApplicationUser appuser = await manager.FindAsync(uxLogin.UserName, uxLogin.Password);
I use
ApplicationUser appuser = manager.FindAsync(uxLogin.UserName, uxLogin.Password).Result;
to solve this problem

Hope this help.

วันอังคารที่ 13 พฤษภาคม พ.ศ. 2557

Application pool 'xxx' is being automatically disabled due to a series of failures in the process(es) serving that application pool.

Today got another Hard time to run some Application in my localhost.
It just simple to make Oracle Provider run by set Enable 32-Bit Applications to True on Application pool advanced settings

but this time my IIS crash and don't know why?.
I just only create new Application Pools and set it to support 32 bit Application.

Go to Windows Logs > System it show Error

"Application pool 'xxx' is being automatically disabled due to a series of failures in the process(es) serving that application pool."

this error not much help My application work fine when run Debug and if use Default Application pool it work fine except can't use Oracle Provider.

After some research I can't find any answer directly but got some clues.

Application Pool Need permission to work too.

In Application Pool in Advanced Settings we have "Process Model > Identity" that it auto generate when create new Application pool. I assume that Identity don't have some permission on something but I don't have time to find about that. so I change Identity to "NetworkService" and the problem is gone.

Hope this help.

วันศุกร์ที่ 9 พฤษภาคม พ.ศ. 2557

Visual Studio Extensions for Windows Library for JavaScript in VS 2013 won't update correctly.

After click update it will continue to show last version and can't update anymore but show repair and uninstall instead.
after some research to make it work we need tool call "msiinv" to uninstall old version (for me is 2 version 1.x and 1 version for 2.x)

here is ref
http://stackoverflow.com/questions/22960240/after-installing-visual-studio-extensions-for-windows-library-for-javascript-u

go to download msiinv from
http://blogs.msdn.com/b/astebner/archive/2005/07/01/using-msiinv-to-gather-information-about-what-is-installed-on-a-computer.aspx

uninstall zip package in c:\msiinv and run command
msiinv.exe -p > out.txt

now look in out.txt for 
"Visual Studio Extensions for Windows Library for JavaScript"

uninstall any old version by 
msiexec /x {product code}
ex.
msiexec /x {D5FEB7A1-5D0F-4CDC-8290-F52DFB53AF23}

hope this help.

วันอังคารที่ 25 กุมภาพันธ์ พ.ศ. 2557

Amazon EC2 Windows Activate problem

Today my Windows Server on EC 2 ask me to activate but it failed when activate online.
After some research I found this can help.

1. go to C:\Program Files\Amazon\Ec2ConfigService\Settings\config.xml  to change setting Ec2WindowsActivate to Enabled
2. go to service and restart service "Ec2Config"

now problem is gone.

วันพุธที่ 4 ธันวาคม พ.ศ. 2556

Allow C# to manager IIS when use Microsoft.Web.Administration

I use reference Microsoft.Web.Administration from
C:\Windows\System32\inetsrv\Microsoft.Web.Administration.dll

to read IIs Status must allow IIS user readable on folder
C:\Windows\System32\inetsrv\config

and to write or change IIS must writable on it.

It can create new user and set to Application pool and allow this user for read and write on above folder.

วันจันทร์ที่ 4 พฤศจิกายน พ.ศ. 2556

IIS Express stop process when stop debug in Visual Studio 2013

This is feature in new Visual Studio call "Enable Edit and Continue"
If don't want to close IIS Express go to Project Properties > Web >
to unchecked "Enable Edit and Continue" to let IIS express continue after stop debug.

this setting is default on when create new Project.

วันศุกร์ที่ 1 พฤศจิกายน พ.ศ. 2556

System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to

[A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to [B]System.Web.WebPages.Razor.Configuration.HostSection. Type A originates from 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Razor\v4.0_2.0.0.0__31bf3856ad364e35\System.Web.WebPages.Razor.dll'. Type B originates from 'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\Users\xxxx\AppData\Local\Temp\Temporary ASP.NET Files\root\fe4980a2\10ea1996\assembly\dl3\33a3ac9e\f6af08a0_f8d6ce01\System.Web.WebPages.Razor.dll'.
This happen today when I use Nuget upgrade my MVC 4 asp.net 4.5 to last version on 1 November 2013 but can't get my project run normally after upgrade.
Normally look like I got System.Web.Razor version 3.0.0.0 but my web still use version 2.0.0.0 so I try to fix this
first change in root web.config by this
from
    <appSettings>
        <add key="webpages:Version" value="2.0.0.0" />
        <add key="webpages:Enabled" value="false" />
        <add key="PreserveLoginUrl" value="true" />
        <add key="ClientValidationEnabled" value="true" />
        <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    </appSettings>
to
    <appSettings>
        <add key="webpages:Version" value="3.0.0.0" />
        <add key="webpages:Enabled" value="false" />
        <add key="PreserveLoginUrl" value="true" />
        <add key="ClientValidationEnabled" value="true" />
        <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    </appSettings>
from
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
            </dependentAssembly>
to
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
            </dependentAssembly>

change in web.config in ~/Views/
    <configSections>
        <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
            <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
            <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
        </sectionGroup>
    </configSections>
to
    <configSections>
        <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
            <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
            <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
        </sectionGroup>
    </configSections>

from
        <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
to
        <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

from
        <pages
            validateRequest="false"
            pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
            pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
            userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
            <controls>
                <add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
            </controls>
        </pages>
to
        <pages
            validateRequest="false"
            pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
            pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
            userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
            <controls>
                <add assembly="System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
            </controls>
        </pages>

now I can run my project with no problem (for now...)
Update...
yes i can build and run but intellisense not work anymore  look like i need Visual Studio 2003 for this job done.

วันพุธที่ 9 ตุลาคม พ.ศ. 2556

This backend version is not supported to design database diagrams or tables. (MS Visual Database Tools)

From previous I try to change table field size in SQL Server Management Studio I got this message appear and can't change anything with my table so I realize I use Server Management 2008R2 but my Database version is 2012 for now so I change Server Management to use version 2012 and it work fine. to avoid this don't use old version to edit new version that's all.

Increase Mantis bug tracker summary field length.

Mantis bug tracker is good but with limit summary filed is not good for me. I need to expand from 128 character to 255 for can fill in more summary for me.

we have 3 place to change.
1. in Database open and go to "mantis_bug_table" in field "summary" expand from varchar(128) to varchar(255)
2. in  source page "bug_report_page.php" and "bug_update_advanced_page.php" go to
line contain
type="text" name="summary" size="105" maxlength="128"
and change it to
type="text" name="summary" size="105" maxlength="255"
u have to change this line in both files.

all done can test and enjoy with more summary field
hint : Current version i used is 1.2.15 and with Ms SQL 2012
then
"bug_report_page.php" change in line 475
and
"bug_update_advanced_page.php" change in line 577

วันอังคารที่ 20 สิงหาคม พ.ศ. 2556

Format number % in High Chart

I try pie chart but it have 2 categories and show 33.33333333333333 % and 66.66666666666666 %
then i try to format this number

in code have 2 part for show this number first is tooltip that will show when mouse over
and label for static show look at

this.percentage

and change it to this

this.percentage.toFixed(2)


hope this help