Body part not save to Db

Topics: Customizing Orchard
Dec 12, 2011 at 10:34 AM

Hi

My body part is working fine until today. Today i have copy website content to body part and save it. After that body part is not working. When i save my article other data going to databse fine. I have check databse. Content Id is body part table but text is null. 

,How can i fix it. 

lakmal

 

Coordinator
Dec 12, 2011 at 7:18 PM

What do you mean by "i have copy website content to body part and save it"?

Dec 13, 2011 at 2:41 AM

When i create article i have copy some text from website and paste it to body. I have checked bodypart table, There is 10 records with same contentid, But text is null. After that i have created some articles but body text always null. Contentid is there

 

lakmal

Coordinator
Dec 13, 2011 at 4:13 AM

Never seen that. Do you have any errors in app_data\logs that could be related to that? Do you have any modules installed that could be modifying body?

Dec 13, 2011 at 6:00 AM

This is last error log

 

2011-12-13 12:48:11,437 [4] Orchard.Environment.Extensions.ExtensionLoaderCoordinator - No loader found for extension "NGM.ContentViewCounter2"!2011-12-13 12:48:19,281 [9] Orchard.Environment.Extensions.ExtensionManager - No suitable loader found for extension "NGM.ContentViewCounter2"2011-12-13 12:50:48,453 [9] Orchard.Environment.Extensions.ExtensionLoaderCoordinator - No loader found for extension "NGM.ContentViewCounter2"!2011-12-13 12:50:48,593 [4] Orchard.Environment.Extensions.ExtensionManager - No suitable loader found for extension "NGM.ContentViewCounter2"2011-12-13 12:51:10,109 [4] Orchard.Environment.Extensions.ExtensionLoaderCoordinator - No loader found for extension "NGM.ContentViewCounter2"!2011-12-13 12:51:12,125 [8] Orchard.Environment.Extensions.ExtensionManager - No suitable loader found for extension "NGM.ContentViewCounter2"2011-12-13 12:56:39,968 [4] Orchard.ContentManagement.Drivers.Coordinators.ContentPartDriverCoordinator - HttpRequestValidationException thrown from IContentPartDriver by Orchard.Core.Common.Drivers.BodyPartDriverSystem.Web.HttpRequestValidationException (0x80004005): A potentially dangerous Request.Form value was detected from the client (Body.Text="<p>fghdfh</p><p>df...").
Server stack trace:    at System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection)   at Microsoft.Web.Infrastructure.DynamicValidationHelper.ValidationUtility.CollectionReplacer.<>c__DisplayClass12.<ReplaceCollection>b__d(String value, String key)   at Microsoft.Web.Infrastructure.DynamicValidationHelper.LazilyEvaluatedNameObjectEntry.ValidateObject()   at Microsoft.Web.Infrastructure.DynamicValidationHelper.LazilyValidatingHashtable.get_Item(Object key)   at System.Collections.Specialized.NameObjectCollectionBase.FindEntry(String key)   at System.Collections.Specialized.NameValueCollection.GetValues(String name)   at System.Web.Mvc.NameValueCollectionValueProvider.ValueProviderResultPlaceholder.GetResultFromCollection(String key, NameValueCollection collection, CultureInfo culture)   at System.Web.Mvc.NameValueCollectionValueProvider.ValueProviderResultPlaceholder.<>c__DisplayClass4.<.ctor>b__0()   at System.Lazy`1.CreateValue()

 

Dec 14, 2011 at 9:52 AM

Any idea for this error, Seems like its deleting body content

 

Developer
Dec 15, 2011 at 9:01 AM

This is because you tried to save html in the body text and the system detected the <> symbols as dangerous. Not sure when this should really happen but I've seen it when I tried to save an item with BodyPart from the front-end.

Dec 15, 2011 at 9:44 AM

I have change article contenttype body part flavour as text, Then its working fine. 

My item.cshtml file is 

 

@Display(Model)

 

When i view particular article Head is comming with big bold text, But body text comming without any formating, Have u idea how can i get body text with original format?

 

lakmal

Developer
Dec 15, 2011 at 1:01 PM

Text is simple plain text, so that's why there is no formatting. For formatting e.g. the html flavor is needed, but this is causing trouble for you. I don't know why. You're using the built-in admin editors? If not, and you're building you own editor shape from a controller, this won't work. But if you get this exception when editing in the admin, I don't have a clue.

Dec 15, 2011 at 4:57 PM

This is my controller create method, Something wrong there?

  public ActionResult Create()
        {
            if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage Articless")))
                return new HttpUnauthorizedResult();
            var articleVModel = new ArticlesCreateViewModel();


            
            var Articles = Services.ContentManager.New<ArticlesPart>("Articles");
            articleVModel.Articles = Articles;
            //articleVModel.CategoryList = new SelectList(Catlist, "Value", "Text", "CategoryID");
            if (Articles == null)
                return HttpNotFound();

            dynamic model = Services.ContentManager.BuildEditor(Articles);
                         
           
               // Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
            //return View((object)model);
            return View((object)model);
        }
        
        [HttpPost, ActionName("Create")]
        public ActionResult CreatePOST()
        {
            if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage Articless")))
                return new HttpUnauthorizedResult();

            var Articles = Services.ContentManager.New<ArticlesPart>("Articles");

            _contentManager.Create(Articles, VersionOptions.Published);
            dynamic model = _contentManager.UpdateEditor(Articles, this);

            if (!ModelState.IsValid)
            {
                _transactionManager.Cancel();
                // Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
               // return View((object)model);
                return View ();
            }

            _contentManager.Publish(Articles.ContentItem);

           // _categoryPathConstraint.AddPath(Articles.As<IRoutableAspect>().Path);

            return Redirect("~/Admin/eProp.Articles");
        }