<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Avivo Tech Blog &#187; ASP.NET</title>
	<atom:link href="http://tech.avivo.si/category/aspnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://tech.avivo.si</link>
	<description>Solving problems</description>
	<lastBuildDate>Tue, 24 Jan 2012 14:46:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Set IIS binding manually (add and remove IIS binding)</title>
		<link>http://tech.avivo.si/2011/12/set-iis-binding-manually-add-and-remove-iis-binding/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=set-iis-binding-manually-add-and-remove-iis-binding</link>
		<comments>http://tech.avivo.si/2011/12/set-iis-binding-manually-add-and-remove-iis-binding/#comments</comments>
		<pubDate>Fri, 09 Dec 2011 14:22:57 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Silverlight/WPF]]></category>
		<category><![CDATA[adding binding to iis from command line]]></category>
		<category><![CDATA[bindings]]></category>
		<category><![CDATA[change iis bindings from asp.net mvc website]]></category>
		<category><![CDATA[iis 7]]></category>
		<category><![CDATA[iis bindings]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=1422</guid>
		<description><![CDATA[We had an issue that we need to add or remove IIS 7 or IIS 7.5 additional bindings on one web application and we wanted to do this from one of our ASP.NET MVC applications. It is possible so you need to use IIS system program appcmd.exe (you can find it in C:\Windows\System32\inetsrv\ (we suggest [...]]]></description>
			<content:encoded><![CDATA[<p>We had an issue that we need to add or remove IIS 7 or IIS 7.5 <strong>additional bindings</strong> on one web application and we wanted to do this from one of our ASP.NET MVC applications.</p>
<p>It is possible so you need to use IIS system program <strong>appcmd.exe</strong> (you can find it in <strong>C:\Windows\System32\inetsrv\</strong> (we suggest you to put this into your PATH variable)</p>
<h3><strong>Adding additional bindings</strong></h3>
<p>You want to add <strong>your</strong><strong>-subdomain.your-domain.com</strong> binding to your IIS 7 app named <strong>your-domain.com</strong></p>
<p><span style="color: #ff0000;">C:\Windows\System32\inetsrv\appcmd set site /site.name: <strong>your-domain.com</strong> /+bindings.[protocol='http',bindingInformation='*:80:<strong>your-subdomain.your-domain.com</strong>']</span></p>
<h3><strong>Removing existing bindings</strong></h3>
<p>You want to <strong>remove </strong><strong>your</strong><strong>-subdomain.your-domain.com</strong> binding from your IIS 7 app named <strong>your-domain.com </strong>(please notice <strong>- sign</strong> in front of <strong>bindings </strong>word)<strong><br />
</strong></p>
<p><span style="color: #ff0000;">C:\Windows\System32\inetsrv\appcmd set site /site.name: <strong>your-domain.com</strong> /-bindings.[protocol='http',bindingInformation='*:80:<strong>your-subdomain.your-domain.com</strong>']</span></p>
<p>And that&#8217;s it but if you want to run it from ASP.NET you could try to use Process and ProcessInfo classes to run DOS command but there are some permissions problems (we didn&#8217;t investigated much).</p>
<p>Other (alternative way that we tried is directly from the code)<br />
You will need to reference this DLL: <strong>c:\Windows\System32\inetsrv\Microsoft.Web.Administration.dll </strong></p>
<pre>using (ServerManager serverManager = new ServerManager())
{
  if (serverManager.Sites == null)
    throw new SimpleException("There are no IIS applications!");

  var esponceApp = serverManager.Sites.FirstOrDefault(
x =&gt; x.Name == Settings.IISAppName);
  if (esponceApp != null)
  {
    BindingCollection bindingCollection = esponceApp.Bindings;
    Binding binding = bindingCollection.CreateElement("binding");
    binding["protocol"] = "http";
    binding["bindingInformation"] =
string.Format(@"{0}:{1}:{2}", "*", "80", this.DomainName);

    //Remove this binding if already exists.
    int oldBindingIndex = -1;
    int bindingIndex = -1;
    foreach (Binding currentBinding in esponceApp.Bindings)
    {
      if (currentBinding.BindingInformation ==
binding["bindingInformation"].ToString())
      {
        bindingIndex = esponceApp.Bindings.IndexOf(currentBinding);
      }
      if (!string.IsNullOrEmpty(oldDomainName) &amp;&amp;
      currentBinding.BindingInformation ==
string.Format(@"{0}:{1}:{2}", "*", "80", oldDomainName))
      {
        oldBindingIndex = esponceApp.Bindings.IndexOf(currentBinding);
      }
    }
    if (bindingIndex != -1)
    {
      esponceApp.Bindings.RemoveAt(bindingIndex);
    }
    if (oldBindingIndex != bindingIndex &amp;&amp; oldBindingIndex != -1)
    {
      esponceApp.Bindings.RemoveAt(oldBindingIndex);
    }

    //Add this bindings
    bindingCollection.Add(binding);
    serverManager.CommitChanges();
  }
}
}
catch
{
throw new SimpleException("Could not add binding into IIS application!");
}</pre>
<p>Important!<br />
Set identity of your app&#8217;s <strong>Application Domain</strong> from <strong>Advanced Settings &gt; Process Model &gt; Identity &gt; Change &#8220;ApplicationPoolIdentity&#8221; to &#8220;Local System&#8221;</strong></p>
<p>Investigate also security implications if you are not running this in Intranet&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2011/12/set-iis-binding-manually-add-and-remove-iis-binding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Increasing maximum request length for WCF REST Web Service with ASP .NET 4.0</title>
		<link>http://tech.avivo.si/2011/10/increase-maximum-request-length-for-wcf-rest-web-service-asp-net-4/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=increase-maximum-request-length-for-wcf-rest-web-service-asp-net-4</link>
		<comments>http://tech.avivo.si/2011/10/increase-maximum-request-length-for-wcf-rest-web-service-asp-net-4/#comments</comments>
		<pubDate>Wed, 26 Oct 2011 18:50:22 +0000</pubDate>
		<dc:creator>developer</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[asp .net 4.0]]></category>
		<category><![CDATA[behavior]]></category>
		<category><![CDATA[binding]]></category>
		<category><![CDATA[request length]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[wcf]]></category>
		<category><![CDATA[web service]]></category>
		<category><![CDATA[web.config]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=1407</guid>
		<description><![CDATA[Recently we have extended a web service with method for uploading user&#8217;s profile image. So far the service was working fine with less amount of data, i.e. name, address and description. First image upload test with the new method resulted with 400 Bad Request. Breakpoints were set in WCF method but debugger did not stop [...]]]></description>
			<content:encoded><![CDATA[<p>Recently we have extended a web service with method for uploading user&#8217;s profile image. So far the service was working fine with less amount of data, i.e. name, address and description. First <strong>image upload test</strong> with the new method resulted with <strong>400 Bad Request</strong>. Breakpoints were set in <strong>WCF method</strong> but debugger did not stop there, not even entered the method.</p>
<h2>Default configuration</h2>
<p>WCF service had been configured for REST using default webHttpBinding configuration in web.config</p>
<pre>&lt;configuration&gt;
  ...
  &lt;system.serviceModel&gt;
    &lt;behaviors&gt;
      &lt;endpointBehaviors&gt;
        &lt;behavior name="ApiBehavior" /&gt;
      &lt;/endpointBehaviors&gt;
      &lt;serviceBehaviors&gt;
        &lt;behavior name="Avivo.Web.Services.ApiServiceBehavior"&gt;
         &lt;serviceMetadata httpGetEnabled="true" /&gt;
         &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt;
         &lt;serviceTimeouts transactionTimeout="00:05:00" /&gt;
        &lt;/behavior&gt;
      &lt;/serviceBehaviors&gt;
    &lt;/behaviors&gt;

    &lt;services&gt;
      &lt;!-- API v1.0 --&gt;
      &lt;service behaviorConfiguration="Avivo.Web.Services.ApiServiceBehavior"
name="Avivo.Web.Services.ApiService"&gt;
        &lt;host&gt;
          &lt;baseAddresses&gt;
            &lt;add baseAddress="http://localhost:1234/api/v1" /&gt;
          &lt;/baseAddresses&gt;
        &lt;/host&gt;
        &lt;endpoint address="" binding="webHttpBinding"
contract="Avivo.Web.Services.IApiService" behaviorConfiguration="ApiBehavior" /&gt;
      &lt;/service&gt;
    &lt;/services&gt;

    &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true"&gt;
      &lt;baseAddressPrefixFilters&gt;
        &lt;add prefix="http://localhost:1234/api/v1"/&gt;
      &lt;/baseAddressPrefixFilters&gt;
    &lt;/serviceHostingEnvironment&gt;

  &lt;/system.serviceModel&gt;
  ...
&lt;/configuration&gt;</pre>
<h2>Identifying the problem</h2>
<p>Images can be quite large (few MB), especially when comparing with text size (few KB). At first it was assumed the web service call has <strong>exceeded maximum request length limit</strong>. To confirm the assumption we analyzed WCF traffic using <strong>SvcTraceViewer</strong>.</p>
<p>Enabling WCF tracing in web.config</p>
<pre>&lt;configuration&gt;
  ...
  &lt;!-- Use SvcTraceViewer for debugging WCF services --&gt;
  &lt;system.diagnostics&gt;
    &lt;trace autoflush="true" /&gt;
    &lt;sources&gt;
      &lt;source name="System.ServiceModel" switchValue="Information,
ActivityTracing" propagateActivity="true"&gt;
        &lt;listeners&gt;
          &lt;add name="sdt" type="System.Diagnostics.XmlWriterTraceListener"
initializeData="d:\temp\wcf-trace.svclog" /&gt;
        &lt;/listeners&gt;
      &lt;/source&gt;
    &lt;/sources&gt;
  &lt;/system.diagnostics&gt;
  ...
&lt;/configuration&gt;</pre>
<p>When the tracing is set each request to web service will write entry to d:\temp\wcf-trace.svclog in this case. The report file can be opened with <strong>SvcTraceViewer</strong> found in <strong>%ProgramFiles%\Microsoft SDKs\Windows</strong>, e.g. &#8220;c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\SvcTraceViewer.exe&#8221;</p>
<p>Entries in SvcTraceViewer marked with red represents errors. The problematic request was logged with error message:</p>
<pre>The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.</pre>
<p>Identifying that assumption was right and the upload request exceeded <strong>default 65 KB limit</strong>.</p>
<h2>Increasing request limit quota</h2>
<p>Customizing <strong>webHttpBinding</strong> in web.config and referencing with <strong>bindingConfiguration</strong> in endpoint element</p>
<pre>&lt;configuration&gt;
        ...
  &lt;system.serviceModel&gt;
        ...
    &lt;bindings&gt;
      &lt;!-- Customizations for REST service --&gt;
      &lt;webHttpBinding&gt;
        &lt;!-- Limits set to 10 MB (specified value in bytes) --&gt;
        &lt;binding name="ApiQuotaBinding" maxReceivedMessageSize="10485760"
maxBufferPoolSize="10485760" maxBufferSize="10485760" closeTimeout="00:03:00"
openTimeout="00:03:00" receiveTimeout="00:10:00" sendTimeout="00:03:00"&gt;
          &lt;readerQuotas maxDepth="32" maxStringContentLength="10485760"
maxArrayLength="10485760" maxBytesPerRead="10485760" /&gt;
          &lt;security mode="None" /&gt;
        &lt;/binding&gt;
      &lt;/webHttpBinding&gt;
    &lt;/bindings&gt;

    &lt;services&gt;
      &lt;!-- API v1.0 --&gt;
      &lt;service behaviorConfiguration="Avivo.Web.Services.ApiServiceBehavior"
name="Avivo.Web.Services.ApiService"&gt;
        &lt;host&gt;
          &lt;baseAddresses&gt;
            &lt;add baseAddress="http://localhost:1234/api/v1" /&gt;
          &lt;/baseAddresses&gt;
        &lt;/host&gt;
        &lt;!-- Added attribute 'bindingConfiguration' --&gt;
        &lt;endpoint address="" bindingConfiguration="ApiQuotaBinding" binding="webHttpBinding"
contract="Avivo.Web.Services.IApiService" behaviorConfiguration="ApiBehavior" /&gt;
      &lt;/service&gt;
    &lt;/services&gt;

  &lt;/system.serviceModel&gt;
  ...
&lt;/configuration&gt;</pre>
<p>Additionally <strong>httpRuntime</strong> limits must also be set because web service is running in ASP .NET compatibilty mode. Note that maxRequestLength has value in kilobytes.</p>
<pre>&lt;configuration&gt;
  ...
  &lt;system.web&gt;
    &lt;httpRuntime maxRequestLength="10240" /&gt;
  &lt;/system.web&gt;
  ...
&lt;/configuration&gt;</pre>
<h2>Testing</h2>
<p>Finding the solution was not straightforward, it took some time searching the web and reading documentation. Finally after figuring out the described config in this post we solved the problem with success.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2011/10/increase-maximum-request-length-for-wcf-rest-web-service-asp-net-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create random web hex color in C# / ASP.NET MVC</title>
		<link>http://tech.avivo.si/2011/04/create-random-web-hex-color-in-c-asp-net-mvc/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=create-random-web-hex-color-in-c-asp-net-mvc</link>
		<comments>http://tech.avivo.si/2011/04/create-random-web-hex-color-in-c-asp-net-mvc/#comments</comments>
		<pubDate>Fri, 22 Apr 2011 22:46:16 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[colour]]></category>
		<category><![CDATA[hash color]]></category>
		<category><![CDATA[random color]]></category>
		<category><![CDATA[web color]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=1305</guid>
		<description><![CDATA[Random random = new Random(); int red = random.Next(0, 255); int green = random.Next(0, 255); int blue = random.Next(0, 255); string hexColour = String.Format("#{0:X2}{1:X2}{2:X2}", red, green, blue);]]></description>
			<content:encoded><![CDATA[<pre class=csharp>
Random random = new Random();
int red = random.Next(0, 255);
int green = random.Next(0, 255);
int blue = random.Next(0, 255);
string hexColour = String.Format("#{0:X2}{1:X2}{2:X2}", red, green, blue);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2011/04/create-random-web-hex-color-in-c-asp-net-mvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to trim leading and trailing HTML spaces in C#</title>
		<link>http://tech.avivo.si/2010/12/how-to-trim-leading-and-trailing-html-spaces-in-c/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-trim-leading-and-trailing-html-spaces-in-c</link>
		<comments>http://tech.avivo.si/2010/12/how-to-trim-leading-and-trailing-html-spaces-in-c/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 12:27:52 +0000</pubDate>
		<dc:creator>developer</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[remove trailing and leading html spaces]]></category>
		<category><![CDATA[trim]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=948</guid>
		<description><![CDATA[Some HTML WYSIWYG editors create &#8216;br&#8217; tags or leave &#8216;&#38;nbsp;&#8217; garbage spaces when no content is entered. Described TrimWhiteSpaces method is useful when you need to determine if user left blank content in WYSIWYG editor or if you just want to clean HTML code. TrimWhiteSpaces accepts raw HTML content and removes white spaces, tabs, new [...]]]></description>
			<content:encoded><![CDATA[<p>Some HTML WYSIWYG editors create &#8216;br&#8217; tags or leave &#8216;&amp;nbsp;&#8217; garbage spaces when no content is entered. Described <strong>TrimWhiteSpaces </strong>method is useful when you need to determine if user left blank content in WYSIWYG editor or if you just want to clean HTML code.</p>
<p><strong>TrimWhiteSpaces</strong> accepts raw HTML content and removes white spaces, tabs, new line characters, &#8216;br&#8217; tags and &#8216;&amp;nbsp;&#8217; chunks from before and after the actual content.</p>
<pre class=csharp>
public static string TrimWhiteSpaces(string html)
{
  string result = html;

  //Remove leading spaces
  result = Regex.Replace(result, @"<span style="color: red;">^(?&lt;leading&gt;(\s|\r|\n|\&lt;br\s*/?\&gt;|&amp;nbsp;)*)</span>", "",
RegexOptions.IgnoreCase);

  //Remove trailing spaces
  result = Regex.Replace(result, @"<span style="color: red;">(?&lt;trailing&gt;(\s|\r|\n|\&lt;br\s*/?\&gt;|&amp;nbsp;)*)$</span>", "",
RegexOptions.IgnoreCase);

  return result;
}
</pre>
<div style="margin-top:20px;">
<strong>Example:</strong>
</div>
<div style="margin-top:20px;">
<strong>Input:</strong></p>
<pre><span style="color: red;">&amp;nbsp;&lt;br /&gt;&lt;BR   &gt;&lt;BR&gt; &amp;nbsp;
&amp;nbsp;&amp;nbsp;&lt;br /&gt;</span><span style="color: blue;">
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/p&gt;
&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&lt;p&gt;Pellentesque lorem neque, accumsan eget euismod ut, tristique et odio.&lt;/p&gt;</span>
<span style="color: red;">&amp;nbsp;&lt;br /&gt; &lt;br&gt;
&amp;nbsp;</span>
</pre>
</div>
<div style="margin-top:20px;">
<strong>Output:</strong></p>
<pre class=csharp>
<span style="color: blue;">
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/p&gt;
&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&lt;p&gt;Pellentesque lorem neque, accumsan eget euismod ut, tristique et odio.&lt;/p&gt;
</span>
</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/12/how-to-trim-leading-and-trailing-html-spaces-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parsing URL query string into key-value pairs in C#</title>
		<link>http://tech.avivo.si/2010/12/parsing-url-query-string-into-key-value-pairs-in-c/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=parsing-url-query-string-into-key-value-pairs-in-c</link>
		<comments>http://tech.avivo.si/2010/12/parsing-url-query-string-into-key-value-pairs-in-c/#comments</comments>
		<pubDate>Fri, 03 Dec 2010 12:08:31 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[key-value pairs from query string]]></category>
		<category><![CDATA[parsing query string]]></category>
		<category><![CDATA[query string]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=917</guid>
		<description><![CDATA[Imagine you have URL something like this: http://www.yourdomain.com?param1=value1&#38;param2=value2&#38;param3=value3&#38;param4=value4 and you want to get key-value pairs such as {&#8220;param1&#8243;, &#8220;param2&#8243;, &#8220;param3&#8243;, &#8220;param4&#8243;} {&#8220;value1&#8243;, &#8220;value2&#8243;, &#8220;value3&#8243;, &#8220;value4&#8243;} It is easy to do using system function: using System.Collections.Specialized; NameValueCollection query = HttpUtility.ParseQueryString(queryString); Response.Write(query["param1"]);]]></description>
			<content:encoded><![CDATA[<p>Imagine you have URL something like this:</p>
<p><strong>http://www.yourdomain.com?param1=value1&amp;param2=value2&amp;param3=value3&amp;param4=value4</strong></p>
<p>and you want to get key-value pairs such as</p>
<ul>
<li>{&#8220;param1&#8243;, &#8220;param2&#8243;, &#8220;param3&#8243;, &#8220;param4&#8243;}</li>
<li>{&#8220;value1&#8243;, &#8220;value2&#8243;, &#8220;value3&#8243;, &#8220;value4&#8243;}</li>
</ul>
<p>It is easy to do using system function:</p>
<pre class=charp>
using System.Collections.Specialized;
NameValueCollection query = HttpUtility.ParseQueryString(queryString);
Response.Write(query["param1"]);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/12/parsing-url-query-string-into-key-value-pairs-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The service cannot be activated due to an exception during compilation. The exception message is: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.</title>
		<link>http://tech.avivo.si/2010/11/the-service-cannot-be-activated-due-to-an-exception-during-compilation-the-exception-message-is-this-collection-already-contains-an-address-with-scheme-http-there-can-be-at-most-one-address-per-sch/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-service-cannot-be-activated-due-to-an-exception-during-compilation-the-exception-message-is-this-collection-already-contains-an-address-with-scheme-http-there-can-be-at-most-one-address-per-sch</link>
		<comments>http://tech.avivo.si/2010/11/the-service-cannot-be-activated-due-to-an-exception-during-compilation-the-exception-message-is-this-collection-already-contains-an-address-with-scheme-http-there-can-be-at-most-one-address-per-sch/#comments</comments>
		<pubDate>Thu, 25 Nov 2010 14:38:51 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Silverlight/WPF]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[The service cannot be activated due to an exception during compilation]]></category>
		<category><![CDATA[There can be at most one address per scheme in this collection]]></category>
		<category><![CDATA[This collection already contains an address with scheme http]]></category>
		<category><![CDATA[wcf]]></category>
		<category><![CDATA[wcf service error]]></category>
		<category><![CDATA[web service]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=825</guid>
		<description><![CDATA[You can solve this issue by adding the following code to your web.config: &#60;system.serviceModel&#62; ... &#60;serviceHostingEnvironment&#62; &#60;baseAddressPrefixFilters&#62; &#60;add prefix="http://sample.domain.tld/Sample/"/&#62; &#60;/baseAddressPrefixFilters&#62; &#60;/serviceHostingEnvironment&#62; ... &#60;/system.serviceModel&#62;]]></description>
			<content:encoded><![CDATA[<p>You can solve this issue by adding the following code to your web.config: </p>
<pre class=xml>
&lt;system.serviceModel&gt;
	...
	&lt;serviceHostingEnvironment&gt;
	  &lt;baseAddressPrefixFilters&gt;
	  	&lt;add prefix="http://sample.domain.tld/Sample/"/&gt;
	  &lt;/baseAddressPrefixFilters&gt;
	&lt;/serviceHostingEnvironment&gt;
	...
&lt;/system.serviceModel&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/11/the-service-cannot-be-activated-due-to-an-exception-during-compilation-the-exception-message-is-this-collection-already-contains-an-address-with-scheme-http-there-can-be-at-most-one-address-per-sch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compiler Error Message: CS0016: Could not write to output file &#8211; Temporary ASP.NET Files &#8211; Access is denied</title>
		<link>http://tech.avivo.si/2010/11/compiler-error-message-cs0016-could-not-write-to-output-file-temporary-asp-net-files-access-is-denied/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=compiler-error-message-cs0016-could-not-write-to-output-file-temporary-asp-net-files-access-is-denied</link>
		<comments>http://tech.avivo.si/2010/11/compiler-error-message-cs0016-could-not-write-to-output-file-temporary-asp-net-files-access-is-denied/#comments</comments>
		<pubDate>Thu, 11 Nov 2010 13:30:31 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[System administration]]></category>
		<category><![CDATA[Access is denied]]></category>
		<category><![CDATA[App_GlobalResources.xxxxxxx.dll]]></category>
		<category><![CDATA[Compiler Error Message]]></category>
		<category><![CDATA[CS0016: Could not write to output file]]></category>
		<category><![CDATA[iis 7 error]]></category>
		<category><![CDATA[iis error]]></category>
		<category><![CDATA[v2.0.50727\Temporary ASP.NET Files]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=808</guid>
		<description><![CDATA[Everything was working perfectly and then suddenly during ASP.NET (MVC) development you got this error from your IIS 7 server (in our case from Windows 7 64-bit): Compiler Error Message: CS0016: Could not write to output file ‘c:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\myapp\xxxxx\xxxxx\App_GlobalResources.xxxxxxx.dll’ — &#8216;Access is denied.&#8217; So, what goes wrong? You don&#8217;t know because it was working [...]]]></description>
			<content:encoded><![CDATA[<p>Everything was working perfectly and then suddenly during ASP.NET (MVC) development you got this error from your IIS 7 server (in our case from Windows 7 64-bit):<br />
<strong><span style="color: #ff0000;">Compiler Error Message: CS0016: Could not write to output file ‘c:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\myapp\xxxxx\xxxxx\App_GlobalResources.xxxxxxx.dll’ — &#8216;Access is denied.&#8217;</span></strong><br />
So, what goes wrong? You don&#8217;t know because it was working perfectly previous day, it is also compiles OK but not working anymore on your IIS webserver and, all you got, is yellow screen with this error message.</p>
<h4 style="margin-bottom: 25px;"><strong>We searched a little bit and found that the problem appeared because the permission were lost on following Temporary folders:</strong></h4>
<pre style="margin-bottom: 25px;" lang="text">C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\

C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\

C:\Windows\Temp
</pre>
<h4><strong>Recipe</strong></h4>
<ul>
<li>Gave a full permission to NETWORK SERVICE user to these folders (extreme case is to give full permission to Everyone user to these folders &#8211; do this only it doesn&#8217;t work)</li>
<li>Restart IIS using <strong>iisreset </strong>command</li>
</ul>
<p>IIS started to serve pages again&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/11/compiler-error-message-cs0016-could-not-write-to-output-file-temporary-asp-net-files-access-is-denied/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Publish on Twitter nice and easy from ASP.NET MVC (C#)</title>
		<link>http://tech.avivo.si/2010/09/publish-on-twitter-from-asp-net-mvc-csharp-nice-and-easy/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=publish-on-twitter-from-asp-net-mvc-csharp-nice-and-easy</link>
		<comments>http://tech.avivo.si/2010/09/publish-on-twitter-from-asp-net-mvc-csharp-nice-and-easy/#comments</comments>
		<pubDate>Sun, 19 Sep 2010 19:59:54 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[Social networks]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[change twitter status in c#]]></category>
		<category><![CDATA[dev.twitter.com]]></category>
		<category><![CDATA[OAuth]]></category>
		<category><![CDATA[publish message on twitter from asp.net mvc or c#]]></category>
		<category><![CDATA[put message on twitter]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[twitter authentication]]></category>
		<category><![CDATA[twitterizer]]></category>
		<category><![CDATA[twitting]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=614</guid>
		<description><![CDATA[How can you automatically post message to Twitter from C#, ASP.NET MVC (from your application)? First, setup new Twitter application under your Twitter account. Go to dev.twitter.com and login with your Twitter account Click on Add Application and enter the all needed data You will get all all needed secret keys and tokens and they [...]]]></description>
			<content:encoded><![CDATA[<p>How can you automatically post message to Twitter from C#, ASP.NET MVC (from your application)?</p>
<p>First, setup new Twitter application under your Twitter account.</p>
<ol>
<li>Go to <a href="http://dev.twitter.com" target="_blank">dev.twitter.com</a> and login with your Twitter account</li>
<li>Click on Add Application and enter the all needed data</li>
</ol>
<p>You will get all all needed secret keys and tokens and they are needed for automatic tweeting.</p>
<ul>
<li><strong>Consumer key:</strong> xxxxxxxxxxxxxxxxxxxxx</li>
<li><strong>Consumer secret:</strong> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</li>
<li><strong>Access Token (oauth_token):</strong> xxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</li>
<li><strong>Access Token Secret (oauth_token_secret):</strong> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</li>
</ul>
<p>Now, download <a title="Twitterizer" href="http://www.twitterizer.net/downloads/" target="_blank">Twitterizer API</a></p>
<ol>
<li>reference <strong>Twitterizer2.dll</strong></li>
<li>Put this code into your application (of course change the location from where you get your secret keys &#8211; we have a <strong>Settings </strong> class)</li>
</ol>
<pre lang="csharp">public void PublishOnTwitter(string message)
{
	OAuthTokens tokens = new OAuthTokens();
	tokens.ConsumerKey = Settings.TwitterConsumerKey;
	tokens.ConsumerSecret = Settings.TwitterConsumerSecret;
	tokens.AccessToken = Settings.TwitterToken;
	tokens.AccessTokenSecret = Settings.TwitterTokenSecret;

	TwitterStatus status = TwitterStatus.Update(tokens, message);
}</pre>
<p>And that&#8217;s it!<br />
Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/09/publish-on-twitter-from-asp-net-mvc-csharp-nice-and-easy/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to get user&#8217;s (visitor&#8217;s) IP address in your ASP.NET (MVC) application?</title>
		<link>http://tech.avivo.si/2010/09/how-to-get-users-visitors-ip-address-in-your-asp-net-mvc-application/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-get-users-visitors-ip-address-in-your-asp-net-mvc-application</link>
		<comments>http://tech.avivo.si/2010/09/how-to-get-users-visitors-ip-address-in-your-asp-net-mvc-application/#comments</comments>
		<pubDate>Thu, 16 Sep 2010 08:27:04 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[collect remote IP address of website user]]></category>
		<category><![CDATA[get ip address in asp.net mvc]]></category>
		<category><![CDATA[get ip address in c#]]></category>
		<category><![CDATA[get visitor's IP address]]></category>
		<category><![CDATA[obtain IP address]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=589</guid>
		<description><![CDATA[Extend HttpRequest by writting and extension: using System; using System.Web; using System.Net; using System.Linq; using System.Data.Linq; namespace Some.Yours.Namespace { /// &#60;summary&#62; /// Extends HttpRequest class with additional methods. /// &#60;/summary&#62; public static class HttpRequestExtensions { /// &#60;summary&#62; /// Gets the IP address of the request. /// This method is more useful than built in because [...]]]></description>
			<content:encoded><![CDATA[<p>Extend HttpRequest by writting and extension:</p>
<pre lang=csharp>
using System;
using System.Web;
using System.Net;
using System.Linq;
using System.Data.Linq;

namespace Some.Yours.Namespace
{
  /// &lt;summary&gt;
  /// Extends HttpRequest class with additional methods.
  /// &lt;/summary&gt;
  public static class HttpRequestExtensions
  {
    /// &lt;summary&gt;
    /// Gets the IP address of the request.
    /// This method is more useful than built in because in
    /// some cases it may show real user IP address even under proxy.
    /// The &lt;see cref="System.Net.IPAddress.None" /&gt; value
    /// will be returned if getting is failed.
    /// &lt;/summary&gt;
    /// &lt;param name="request"&gt;The HTTP request object.&lt;/param&gt;
    /// &lt;returns&gt;IPAddress object&lt;/returns&gt;
    public static IPAddress GetIp(this HttpRequestBase request)
    {
      string ipString;
      if (string.IsNullOrEmpty(request.ServerVariables["HTTP_X_FORWARDED_FOR"]))
      {
        ipString = request.ServerVariables["REMOTE_ADDR"];
      }
      else
      {
        ipString = request.ServerVariables["HTTP_X_FORWARDED_FOR"]
           .Split(",".ToCharArray(),
           StringSplitOptions.RemoveEmptyEntries).FirstOrDefault();
      }

      IPAddress result;
      if (!IPAddress.TryParse(ipString, out result))
      {
        result = IPAddress.None;
      }

      return result;
    }
  }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/09/how-to-get-users-visitors-ip-address-in-your-asp-net-mvc-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PDF files not Publish in ASP.NET MVC when deploying</title>
		<link>http://tech.avivo.si/2010/06/pdf-files-not-publish-in-asp-net-mvc-when-deploying/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pdf-files-not-publish-in-asp-net-mvc-when-deploying</link>
		<comments>http://tech.avivo.si/2010/06/pdf-files-not-publish-in-asp-net-mvc-when-deploying/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 12:28:51 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[deploy web application]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[pdf files not published]]></category>
		<category><![CDATA[publish]]></category>
		<category><![CDATA[publish pdf files in asp.net mvc]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=523</guid>
		<description><![CDATA[We faced a problem when we added some PDF files into our media library of ASP.NET MVC website and noticed that these files are not Published automatically. So you need in Visual Studio to click on each PDF file and under Properties (F4) just choose Build Action=Content Copy to Output Directory=Copy Always]]></description>
			<content:encoded><![CDATA[<p>We faced a problem when we added some PDF files into our media library of ASP.NET MVC website and noticed that these files are not Published automatically.<br />
So you need in Visual Studio to click on each PDF file and under Properties (F4) just choose <strong></strong></p>
<ul>
<li><strong>Build Action=Content</strong></li>
<li><strong>Copy to Output Directory=Copy Always</strong></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/06/pdf-files-not-publish-in-asp-net-mvc-when-deploying/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

