PDA

View Full Version : code behind یا InLineCode



shahramasp
شنبه 05 اسفند 1385, 00:20 صبح
سلام بر دوستانو اساتید
کدام روش بهتره code behind یا InLineCode و چرا؟؟
البته خود من از code behind به سفارش خود ماکروسافت استفاده می کنم ولی تو زمان Publish پدرم در میاد !!! یعنی کافیه یه اشکالی رو ساتی که فرستادم رو هاست باشه دوباره باید همه فایلها رو Publish کنم و مجدد همه فایلها رو آپ لود کنم فقط به خاطر یه اشکال در یک فایل :اشتباه: :عصبانی++: اگه مشه یکم در این مورد راهنمایی کنین
متشکرم

Alireza_Salehi
شنبه 05 اسفند 1385, 07:57 صبح
شما می تونی موقع پابلیش گزینه Use fixed naming and Single page assemblies
رو انتخاب کنی ، با این کار به ازای هر صفحه اسمبلی جدا میسازه و اگر ارور داد فقط کافیه همون یه دونه اسمبلی رو عوض کنی که ارور داده!

در مورد بهتر یا بدتر بودنش هم قبلا صحبت شده جستجو کن.
http://www.barnamenevis.org/forum/showthread.php?t=59677&highlight=Code

hamed_bostan
شنبه 05 اسفند 1385, 08:53 صبح
به مطلب مهمی اشاره کردین اما من دو تا لینکی که دوستمون arsp_2004 (http://barnamenevis.org/forum/member.php?u=33355) گذاشتن رو خوندن اما حتی متوجه نشدم کدوم بهتره و یا توی تاپیک ها دیدم اشاره هایی به امنیت شده . کدوم مدل publish بهتره اگه ممکنه بگین .

Alireza_Salehi
شنبه 05 اسفند 1385, 10:01 صبح
راستش من خیلی درمورد امنیت و .. Code Behind جستجو کردم ، مطلب خاصی پیدا نکردم فقط هر جا که سر زدم بدون استثنا همه گفتند از CodeBehind استفاده کنید!

این نکته رو اضافه کنم که Code inline احتیاجی به Publish Web Site نداره و تنها کپی کردن صفحات کفایت میکنه (چون کد ها در فایل aspx قرار دارند-لینک شماره 2).


1.ASP.NET Security in a Sandbox (http://www.theserverside.net/tt/articles/showarticle.tss?id=SandboxingComponents2)
Part 1 illustrated a couple of important practices that should be adopted by any ASP.NET application that requires security, let alone the flexibility of loose coupling and simplified maintenance:
Always use code-behind
Always decouple middle-tier components from the code-behind and application assembly
Strongly name ASP.NET supporting assemblies (not the application assembly) and install them into the Global Assembly Cache (GAC)
Run each component with the lowest possible set of privileges, delay elevation of privileges as long as possible and restore original permissions as soon as possible

2.The great ASP.NET code-behind debate (http://builder.com.com/5100-6387-1049844.html)

Are there proper uses for inline code?

Having given the two main arguments for using code-behind files, I think it’s fair to point out that there are also two times that you may want to use inline code.


You can change inline source code on the fly, and the change will be reflected the next time the page is accessed without having to recompile and redeploy. This harkens back to the old days of ASP programming and has certain advantages, but it flies in the face of any kind of formal change management process.

If you’re writing code specific to the rendering of the display, performance and reusability are enhanced by putting that code inline. Some examples include code for DataGrid binding and Jscript code that displays rendering
3.Introduction to ASP.NET (http://www.programmersheaven.com/articles/arun/aspnet.htm)
Code-Behind logic
The main problem with ASP Classic pages is that an *.asp page does not yield modularized code. Both HTML and Script are present in a single page. But Microsoft's ASP.NET implementation contains a new-fangled method to break up business logic code from presentation code. Each ASPX created in Visual Studio has an equivalent class written in a .NET compliant language such as C#. This class consists of event handlers, initialization code and other supporting code for the user interface in the ASPX file. The C# file that hold this class is called the code-behind file and affords the ASPX file's programmatic implementation.

4.ASP.NET Code Behind Overview (http://support.microsoft.com/kb/303247)

5.Extreme ASP.NET (http://msdn.microsoft.com/msdnmag/issues/06/01/ExtremeASPNET/)

6.The Code Model of ASP.NET 2 (http://www.odetocode.com/Articles/406.aspx)

7.ASP.NET (Wikipedia) (http://en.wikipedia.org/wiki/ASP.NET)

8.Code Behind (wikipedia) (http://en.wikipedia.org/wiki/Code-behind)

9.Meditating Upon the ASP.NET Code-Behind Model (http://www.developer.com/net/csharp/article.php/3087791)


ظاهرا تنها دلیل استفاده نکردن از Code Behind همونیه که در لینک شماره 2 گفته - که البته به نظر من استفاده کردن از Code Behind مزیت های بسیار بیشتری داره مخصوصا در ASP.NET 2!

hamed_bostan
شنبه 05 اسفند 1385, 12:32 عصر
یکی از دوستان کفته بود هنگام publish از گزینه
Use fix name ing and single page assembelies
استفاده کنیم بهتره و ... می خوام ببینم ایا این تو سرعت و امنیت هم تاثیری حاصل میکنه ؟

Alireza_Salehi
شنبه 05 اسفند 1385, 13:35 عصر
یکی از دوستان کفته بود هنگام publish از گزینه
Use fix name ing and single page assembelies
استفاده کنیم بهتره و ... می خوام ببینم ایا این تو سرعت و امنیت هم تاثیری حاصل میکنه ؟

وقتی شما این گزینه رو میزنی به ازای هر صفحه یک اسمبلی جدا در پوشه bin سایت ایجاد میکنه در زمان آپدیت کردن یا رفع خطای صفحات این روش بهتره چون دیگه لازم نیست کل سایت رو دوباره آپلود کنی!

اگر از این گزینه استفاده نکنی همه صفحات رو در یک یا چند اسمبلی ادغام میکنه!

از لحاظ امنیتی و سرعت فرق چندانی نداره (یه سایت آپلود کن تست کن) !
اگر می خوای امنیت بیشتری داشته باشی از گزینه Enable strong naming on precompiled assemblies در قسمت Publish استفاده کن!

ClaimAlireza
شنبه 05 اسفند 1385, 18:55 عصر
اگر می خوای امنیت بیشتری داشته باشی از گزینه Enable strong naming on precompiled assemblies در قسمت Publish استفاده کن![/quote]

میشه بیشتر توضیح بدین.

Alireza_Salehi
شنبه 05 اسفند 1385, 20:33 عصر
اگر می خوای امنیت بیشتری داشته باشی از گزینه Enable strong naming on precompiled assemblies در قسمت Publish استفاده کن!
میشه بیشتر توضیح بدین.


Enable strong naming on precompiled assemblies
Specifies that the generated assemblies are strongly named by using a key file or key container to encode the assemblies and ensure that they have not been tampered with. After you select this check box, you can do the following:
Specify the location of a key file to use to sign the assemblies. If you use a key file, you can select Delay signing, which signs the assembly in two stages: first with the public key file, and then with a private key file that is specified later during a call to the aspnet_compiler.exe command.
Specify the location of a key container from the system's cryptographic service provider (CSP) to use to name the assemblies.
Specify whether to mark the assembly with the AllowPartiallyTrustedCallers (http://msdn2.microsoft.com/en-us/library/microsoft.build.tasks.aspnetcompiler.allowpartiall ytrustedcallers%28VS.80%29.aspx) property, which allows strongly named assemblies to be called by partially trusted code. Without this declaration, only fully trusted code can use such assemblies.